瀏覽代碼

Retry requests when the worker has the connection close

When a tcp_closed or ssl_closed message is handled while ibrowse is
trying to send a request to a worker, ibrowse would incorrectly return a
req_timedout message, when, in fact, the request had not even been
handled.

This patch attempts to avoid that race condition by signalling tcp or
ssl closed messages back to ibrowse differently than a normal exit.
pull/100/head
Andrew Thompson 11 年之前
父節點
當前提交
07d1d75d54
共有 2 個檔案被更改,包括 4 行新增2 行删除
  1. +2
    -0
      src/ibrowse.erl
  2. +2
    -2
      src/ibrowse_http_client.erl

+ 2
- 0
src/ibrowse.erl 查看文件

@ -443,6 +443,8 @@ do_send_req(Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout) ->
{error, sel_conn_closed};
{'EXIT', {normal, _}} ->
{error, req_timedout};
{'EXIT', {connection_closed, _}} ->
{error, sel_conn_closed};
{error, connection_closed} ->
{error, sel_conn_closed};
{'EXIT', Reason} ->

+ 2
- 2
src/ibrowse_http_client.erl 查看文件

@ -215,11 +215,11 @@ handle_info({stream_close, _Req_id}, State) ->
handle_info({tcp_closed, _Sock}, State) ->
do_trace("TCP connection closed by peer!~n", []),
handle_sock_closed(State),
{stop, normal, State};
{stop, connection_closed, State};
handle_info({ssl_closed, _Sock}, State) ->
do_trace("SSL connection closed by peer!~n", []),
handle_sock_closed(State),
{stop, normal, State};
{stop, connection_closed, State};
handle_info({tcp_error, _Sock, Reason}, State) ->
do_trace("Error on connection to ~1000.p:~1000.p -> ~1000.p~n",

Loading…
取消
儲存