Skip to content

Commit

Permalink
Fix conditions to close the backend socket when an error occurs
Browse files Browse the repository at this point in the history
We must close the socket when an error _OTHER_THAN_ 'closed' occurs.
  • Loading branch information
Christopher Faulet authored and vinoski committed Jun 11, 2012
1 parent b10e492 commit 98b6f00
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/yaws_revproxy.erl
Expand Up @@ -86,8 +86,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == sendheaders ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand All @@ -106,8 +106,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == sendcontent ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand All @@ -121,8 +121,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == sendcontent ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand Down Expand Up @@ -150,8 +150,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == sendchunk ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand All @@ -165,8 +165,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == sendchunk ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end
Expand Down Expand Up @@ -257,8 +257,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == recvcontent ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand Down Expand Up @@ -300,8 +300,8 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == recvchunk ->
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
case Reason of
closed -> close(RPState);
_ -> ok
closed -> ok;
_ -> close(RPState)
end,
outXXX(500, Arg)
end;
Expand All @@ -312,6 +312,7 @@ out(#arg{state=RPState}=Arg) when RPState#revproxy.state == recvchunk ->
out(#arg{state=RPState}=Arg) when RPState#revproxy.state == terminate ->
case RPState#revproxy.srvconn_status of
"close" when RPState#revproxy.is_chunked == false -> close(RPState);
"close" -> ok;
_ -> cache_connection(RPState)
end,

Expand Down Expand Up @@ -399,11 +400,11 @@ recv_next_chunk(YawsPid, #arg{state=RPState}=Arg) ->
recv_next_chunk(YawsPid, Arg);
{error, Reason} ->
?Debug("TCP error: ~p~n", [Reason]),
yaws_api:stream_chunk_end(YawsPid),
case Reason of
closed -> close(RPState);
_ -> ok
end,
outXXX(500, Arg)
closed -> ok;
_ -> close(RPState)
end
end.

%%==========================================================================
Expand Down

0 comments on commit 98b6f00

Please sign in to comment.