Created
February 17, 2012 14:48
-
-
Save capflam/1853891 to your computer and use it in GitHub Desktop.
Fix bug in yaws_revproxy (issue #82)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/yaws_revproxy.erl b/src/yaws_revproxy.erl | |
index d44f24f..9859793 100644 | |
--- a/src/yaws_revproxy.erl | |
+++ b/src/yaws_revproxy.erl | |
@@ -310,23 +310,37 @@ ploop(From0, To, Pid) -> | |
%% Before reentering the ploop in expect_header mode (new request/reply), | |
%% We must check the if we need to keep the connection alive | |
%% or if we must close it. | |
-ploop_keepalive(_From = #psock{httpconnection="close"}, _To, _Pid) -> | |
+ploop_keepalive(From = #psock{httpconnection="close"}, _To, _Pid) -> | |
?Debug("Connection closed by proxy: No keep-alive~n",[]), | |
- done; %% Close the connection | |
+ %% Close the connection | |
+ close_backend_socket(From), | |
+ done; | |
ploop_keepalive(From, To, Pid) -> | |
%% Check server reverse proxy keep-alive setting | |
%% TODO: We should get this value from the config file | |
case check_server_keepalive() of | |
- false -> done; %% Close the connection: Server config do not | |
- %% allow proxy keep-alive | |
- true -> ploop(From, To, Pid) %% Try keeping the connection | |
- %% alive => Wait for headers | |
+ false -> | |
+ %% Close the connection: Server config do not allow proxy keep-alive | |
+ close_backend_socket(From), | |
+ done; | |
+ true -> | |
+ %% Try keeping the connection alive => Wait for headers | |
+ ploop(From, To, Pid) | |
end. | |
%% TODO: Get proxy keepalive value in SC record | |
check_server_keepalive() -> | |
?proxy_keepalive. | |
+ | |
+%% Close the socket opened to the backend server. The client socket is managed | |
+%% by the gserv process. | |
+close_backend_socket(#psock{type=server, s=Sock}) -> | |
+ gen_tcp:close(Sock); | |
+close_backend_socket(_) -> | |
+ ok. | |
+ | |
+ | |
%% On the way from the client to the server, we need | |
%% rewrite the Host header | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment