Skip to content

Commit

Permalink
Merge pull request smarkets#15 from erlangpack/14-alpine
Browse files Browse the repository at this point in the history
Fix a compile problem on Alpine Linux. Fixes smarkets#14
  • Loading branch information
mworrell authored Jul 2, 2020
2 parents 90b3dad + a0eea22 commit 09ef470
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ priv/bcrypt_nif.so
logs/*
.eunit
rebar3
.rebar3
.rebar

## libtool
Expand Down
8 changes: 4 additions & 4 deletions c_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ ifeq ($(UNAME_SYS), Darwin)
CFLAGS ?= -O3 -std=c99 -arch x86_64 -Wall -Wmissing-prototypes
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
DRV_LDFLAGS = -flat_namespace -undefined suppress $(ERL_LDFLAGS)
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
DRV_LDFLAGS = $(ERL_LDFLAGS)
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -D_BSD_SOURCE
DRV_LDFLAGS = $(ERL_LDFLAGS)
else # FreeBSD
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
DRV_LDFLAGS = $(ERL_LDFLAGS)
endif
Expand Down
6 changes: 3 additions & 3 deletions src/bcrypt_nif_pool_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ start_child() -> supervisor:start_child(?MODULE, []).
init([]) ->
{ok, PoolSize} = application:get_env(bcrypt, nif_pool_size),
{ok, MaxOverFlow} = application:get_env(bcrypt, nif_pool_max_overflow),

PoolArgs = [
{name, {local, nif_pool}},
{name, {local, bcrypt_nif_pool}},
{nif_pool_size, PoolSize},
{nif_pool_max_overflow, MaxOverFlow},
{worker_module, bcrypt_nif_worker}
],

PoolSpecs = [
poolboy:child_spec(nif_pool, PoolArgs, [])
poolboy:child_spec(bcrypt_nif_pool, PoolArgs, [])
],

{ok, {{one_for_one, 10, 10}, PoolSpecs}}.
10 changes: 5 additions & 5 deletions src/bcrypt_nif_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@

start_link(Args) -> gen_server:start_link(?MODULE, Args, []).

gen_salt() ->
poolboy:transaction(nif_pool, fun(Worker) ->
gen_salt() ->
poolboy:transaction(bcrypt_nif_pool, fun(Worker) ->
gen_server:call(Worker, gen_salt, infinity)
end).

gen_salt(Rounds) ->
poolboy:transaction(nif_pool, fun(Worker) ->
poolboy:transaction(bcrypt_nif_pool, fun(Worker) ->
gen_server:call(Worker, {gen_salt, Rounds}, infinity)
end).


hashpw(Password, Salt) ->
poolboy:transaction(nif_pool, fun(Worker) ->
poolboy:transaction(bcrypt_nif_pool, fun(Worker) ->
gen_server:call(Worker, {hashpw, Password, Salt}, infinity)
end).

init([]) ->
process_flag(trap_exit, true),
process_flag(trap_exit, true),
{ok, Default} = application:get_env(bcrypt, default_log_rounds),
Ctx = bcrypt_nif:create_ctx(),
{ok, #state{default_log_rounds = Default, context = Ctx}}.
Expand Down

0 comments on commit 09ef470

Please sign in to comment.