ferd / dlhttpc

dispcount-based lhttpc fork for massive amounts of requests to limited endpoints
Other
36 stars 17 forks source link

Prevent closing undefined socket #5

Closed loucash closed 9 years ago

loucash commented 9 years ago

@ferd hey, another thing that cause an exception.

I am using {max_connections, bypass} option.

After request server closes connection and sends headers:

{ok,{{400,"Bad Request"},
     [{"Content-Type","application/json"},
      {"Content-Length","111"},
      {"Date","Mon, 17 Nov 2014 16:37:58 GMT"},
      {"Server","Cowboy"},
      {"Connection","close"}],
     <<"body message">>}}

In this situation socket is closed in function: dlhttpc_client:maybe_close_socket/5. So basically reordering patterns in case expression will solve an issue of trying to close socket twice.

TL;DR Exception I was getting:

** exception exit: {function_clause,[{tls,close,
                                          [undefined],
                                          [{file,"tls.erl"},{line,262}]},
                                     {dlhttpc_sock,close,2,
                                                   [{file,"src/dlhttpc_sock.erl"},{line,178}]},
                                     {dlhttpc_client,execute,10,
                                                     [{file,"src/dlhttpc_client.erl"},{line,150}]},
                                     {dlhttpc_client,request,10,
                                                     [{file,"src/dlhttpc_client.erl"},{line,84}]}]}
     in function  dlhttpc:request/9 (src/dlhttpc.erl, line 363)
ferd commented 9 years ago

Seems sane also. Thanks for sanitizing this library!

loucash commented 9 years ago

Sure :+1: