Permalink
Browse files

Resolve merge conflict

  • Loading branch information...
2 parents 741272c + 7739a6a commit cae3376502deed05529dff2af99d4d3db40701f0 Devin Torres committed Aug 12, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/poolboy.erl
View
@@ -95,14 +95,23 @@ overflow(checkout, {FromPid, _}, #state{worker_sup=Sup,
overflow(_Event, _From, State) ->
{reply, ok, overflow, State}.
-full({checkin, Pid}, #state{waiting=Waiting}=State) ->
+full({checkin, Pid}, #state{waiting=Waiting,
+ max_overflow=MaxOverflow}=State) ->
case queue:out(Waiting) of
{{value, {FromPid, _}=From}, Left} ->
Ref = erlang:monitor(process, FromPid),
Monitors = [{Pid, Ref} | State#state.monitors],
gen_fsm:reply(From, Pid),
{next_state, full, State#state{waiting=Left,
monitors=Monitors}};
+ {empty, Empty} when MaxOverflow < 1 ->
+ Workers = queue:in(Pid, State#state.workers),
+ Monitors = case lists:keytake(Pid, 1, State#state.monitors) of
+ {value, {_, Ref}, Left} -> erlang:demonitor(Ref), Left;
+ false -> []
+ end,
+ {next_state, ready, State#state{workers=Workers, waiting=Empty,
+ monitors=Monitors}};
{empty, Empty} ->
dismiss_worker(Pid),
{next_state, overflow, State#state{waiting=Empty}}

0 comments on commit cae3376

Please sign in to comment.