[PATCH 5/5] winhttp: Don't send pong on timeout in socket_receive().

Paul Gofman pgofman at codeweavers.com
Tue Jan 25 17:44:35 CST 2022


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
     As testing involves waiting for timeouts it doesn't look good for inclusion into the test suite.
     I've tested this change separately: https://gist.github.com/gofman/bd2f3b6fd6cbe993e97353560ce81e04
     This test succeeds on Windows for me but fails without this patch in Wine: the server close status received 
     during closing handshake becomes WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS (1002).

     Sending ping instead of pong causes the server to send a pong reply as expected although I still see status
     1002 on close after. Which probably suggests that Windows doesn't send the ping as well (I also tried that with
     WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL socket option set to 15000 and Sleep to 30000).

     Also, while looking at this I spotted that we currently ignore PING application data (which may be present
     according to rfc6455 and should be echoed back with PONG. But I didn't see any server sending pings yet
     and didn't do anything with this part so far.


 dlls/winhttp/request.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 62de9f5cff9..385a4fc4e55 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3600,7 +3600,11 @@ static DWORD socket_receive( struct socket *socket, void *buf, DWORD len, DWORD
             {
                 if (!(socket->opcode & CONTROL_BIT) || (ret = handle_control_frame( socket ))) break;
             }
-            else if (ret == WSAETIMEDOUT) ret = socket_send_pong( socket );
+            else if (ret == WSAETIMEDOUT)
+            {
+                WARN( "timeout, retrying.\n" );
+                continue;
+            }
             if (ret) break;
         }
     }
-- 
2.34.1




More information about the wine-devel mailing list