ソースを参照

Encapsulated conn ets table use in ibrowse_lb

Moved all interactions with ets table tracking
connections to API functions on ibrowse_lb,
to reduce knowledge of ets table and its structure.

Also fixed "bug" where ceiling for pipelining
threshold was different than the set value for increment;
made them the same.
pull/123/head
benjaminplee 10年前
コミット
38242f4fd0
2個のファイルの変更17行の追加13行の削除
  1. +3
    -12
      src/ibrowse_http_client.erl
  2. +14
    -1
      src/ibrowse_lb.erl

+ 3
- 12
src/ibrowse_http_client.erl ファイルの表示

@ -1939,31 +1939,22 @@ to_lower([], Acc) ->
shutting_down(#state{lb_ets_tid = undefined}) ->
ok;
shutting_down(#state{lb_ets_tid = Tid}) ->
catch ets:delete(Tid, self()).
ibrowse_lb:report_connection_down(Tid).
inc_pipeline_counter(#state{is_closing = true} = State) ->
State;
inc_pipeline_counter(#state{lb_ets_tid = undefined} = State) ->
State;
inc_pipeline_counter(#state{lb_ets_tid = Tid} = State) ->
update_counter(Tid, self(), {2,1,99999,9999}),
ibrowse_lb:report_request_underway(Tid),
State.
update_counter(Tid, Key, Args) ->
ets:update_counter(Tid, Key, Args).
dec_pipeline_counter(#state{is_closing = true} = State) ->
State;
dec_pipeline_counter(#state{lb_ets_tid = undefined} = State) ->
State;
dec_pipeline_counter(#state{lb_ets_tid = Tid} = State) ->
_ = try
update_counter(Tid, self(), {2,-1,0,0}),
update_counter(Tid, self(), {3,-1,0,0})
catch
_:_ ->
ok
end,
ibrowse_lb:report_request_complete(Tid),
State.
flatten([H | _] = L) when is_integer(H) ->

+ 14
- 1
src/ibrowse_lb.erl ファイルの表示

@ -14,7 +14,10 @@
-export([
start_link/1,
spawn_connection/6,
stop/1
stop/1,
report_connection_down/1,
report_request_underway/1,
report_request_complete/1
]).
%% gen_server callbacks
@ -68,6 +71,16 @@ stop(Lb_pid) ->
ok
end.
report_connection_down(Tid) ->
catch ets:delete(Tid, self()).
report_request_underway(Tid) ->
catch ets:update_counter(Tid, self(), {2, 1, 9999, 9999}).
report_request_complete(Tid) ->
catch ets:update_counter(Tid, self(), {2, -1, 0, 0}),
catch ets:update_counter(Tid, self(), {3, -1, 0, 0}).
%%====================================================================
%% Server functions
%%====================================================================

読み込み中…
キャンセル
保存