Skip to content

Commit 6b2045d

Browse files
committed
horus: Fix key used to lock concurrent accesses to the function cache
[Why] Using the given `fun()` directly seems ineffective. I think this is because the function can take variables from the environment; for example: Var = value, fun() -> do_something(Var) end. [How] Let's use the same helper that is used to build the function cache key. This is logical as this lock protects this cache as part of its intent.
1 parent 8d80373 commit 6b2045d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/horus.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ to_standalone_fun1(Fun, Options) ->
416416
to_standalone_fun2(Fun, State) ->
417417
case to_cached_standalone_fun(Fun, State) of
418418
undefined ->
419-
Lock = {{horus, Fun}, self()},
419+
Key = standalone_fun_cache_key(State),
420+
Lock = {Key, self()},
420421
global:set_lock(Lock, [node()]),
421422
try
422423
case to_cached_standalone_fun(Fun, State) of

0 commit comments

Comments
 (0)