Browse Source

Don't flush the resp_sent message if connection is closed

Tiny optimization.
Loïc Hoguin 11 years ago
parent
commit
0c0caa3a47
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/cowboy_protocol.erl

+ 1 - 1
src/cowboy_protocol.erl

@@ -512,8 +512,8 @@ next_request(Req, State=#state{req_keepalive=Keepalive, timeout=Timeout},
 				_ -> close
 				_ -> close
 			end,
 			end,
 			%% Flush the resp_sent message before moving on.
 			%% Flush the resp_sent message before moving on.
-			receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
 			if HandlerRes =:= ok, Buffer =/= close ->
 			if HandlerRes =:= ok, Buffer =/= close ->
+					receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
 					?MODULE:parse_request(Buffer,
 					?MODULE:parse_request(Buffer,
 						State#state{req_keepalive=Keepalive + 1,
 						State#state{req_keepalive=Keepalive + 1,
 						until=until(Timeout)}, 0);
 						until=until(Timeout)}, 0);