Browse Source

Merge branch 'fix-leaking-timeout' of https://github.com/jlouis/gproc into jlouis-fix-leaking-timeout

Ulf Wiger 14 years ago
parent
commit
b903351824
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/gproc.erl

+ 6 - 2
src/gproc.erl

@@ -305,15 +305,19 @@ request_wait({n,C,_} = Key, Timeout) when C==l; C==g ->
     TRef = case Timeout of
                infinity -> no_timer;
                T when is_integer(T), T > 0 ->
-                   erlang:start_timer(T, self(), timeout);
+                   erlang:start_timer(T, self(), gproc_timeout);
                _ ->
                    erlang:error(badarg, [Key, Timeout])
            end,
     WRef = call({await,Key,self()}, C),
     receive
         {gproc, WRef, registered, {_K, Pid, V}} ->
+	    case Timeout of
+		no_timer -> ignore;
+		TRef -> erlang:cancel_timer(TRef)
+	    end,
             {Pid, V};
-        {timeout, TRef, timeout} ->
+        {timeout, TRef, gproc_timeout} ->
             cancel_wait(Key, WRef),
             erlang:error(timeout, [Key, Timeout])
     end.