Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #83 from maruthavanan/master

Update counter crashed when select process shutdown.
  • Loading branch information...
commit 76692df488a49737d94bf5b11659dd4c9ddd4f4f 2 parents de0c933 + f7a98b1
@cmullaparthi authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 src/ibrowse_lb.erl
View
13 src/ibrowse_lb.erl
@@ -231,7 +231,9 @@ code_change(_OldVsn, State, _Extra) ->
%%% Internal functions
%%--------------------------------------------------------------------
find_best_connection(Tid, Max_pipe) ->
+ ets:safe_fixtable(Tid, true),
Res = find_best_connection(ets:first(Tid), Tid, Max_pipe),
+ ets:safe_fixtable(Tid, false),
Res.
find_best_connection('$end_of_table', _, _) ->
@@ -240,9 +242,14 @@ find_best_connection(Pid, Tid, Max_pipe) ->
case ets:lookup(Tid, Pid) of
[{Pid, Cur_sz, Speculative_sz}] when Cur_sz < Max_pipe,
Speculative_sz < Max_pipe ->
- ets:update_counter(Tid, Pid, {3, 1, 9999999, 9999999}),
- {ok, Pid};
- _ ->
+ case catch ets:update_counter(Tid, Pid, {3, 1, 9999999, 9999999}) of
+ {'EXIT', _} ->
+ %% The selected process has shutdown
+ find_best_connection(ets:next(Tid, Pid), Tid, Max_pipe);
+ _ ->
+ {ok, Pid}
+ end;
+ _ ->
find_best_connection(ets:next(Tid, Pid), Tid, Max_pipe)
end.
Please sign in to comment.
Something went wrong with that request. Please try again.