diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 0aa4f4d7468187..2eb9697fd1a99a 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -777,14 +777,16 @@ endings either CRLF or LF so 't' is appropriate. #define FOPEN_APPENDTEXT "a" #endif -/* WinSock destroys recv() buffer when send() failed. - * Enabled automatically for Windows and for Cygwin as Cygwin sockets are - * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657 - * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround. +/* Windows workaround to recv before every send, because apparently Winsock + * destroys destroys recv() buffer when send() failed. + * This workaround is now disabled by default since it caused hard to fix bugs. + * Define USE_RECV_BEFORE_SEND_WORKAROUND to enable it. + * https://github.com/curl/curl/issues/657 + * https://github.com/curl/curl/pull/10409 */ #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND) # if defined(WIN32) || defined(__CYGWIN__) -# define USE_RECV_BEFORE_SEND_WORKAROUND +/* # define USE_RECV_BEFORE_SEND_WORKAROUND */ # endif #else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */ # ifdef USE_RECV_BEFORE_SEND_WORKAROUND diff --git a/tests/data/test1517 b/tests/data/test1517 index 5150ff6edf79a1..bc663ab63acde3 100644 --- a/tests/data/test1517 +++ b/tests/data/test1517 @@ -9,7 +9,11 @@ early response # -# This reproduces issue #657, fixed with PR #668 - on Windows +# This test checks to make sure curl can call recv() without failing after a +# send() fails on the same socket (#657). Most OSes should support this +# natively but on Windows curl must be built with a workaround (#668) for the +# test to succeed. The precheck will skip this test on Windows if curl was +# built without the workaround (USE_RECV_BEFORE_SEND_WORKAROUND isn't defined). # # Server-side @@ -39,6 +43,11 @@ http lib%TESTNUMBER +# precheck is a command line to run before the test, to see if we can execute +# the test or not + +./libtest/lib%TESTNUMBER check + HTTP POST, server responds before completed send diff --git a/tests/libtest/lib1517.c b/tests/libtest/lib1517.c index dc6a247a69e5a6..f3961659414e1b 100644 --- a/tests/libtest/lib1517.c +++ b/tests/libtest/lib1517.c @@ -60,6 +60,16 @@ int test(char *URL) struct WriteThis pooh; + if(!strcmp(URL, "check")) { +#if (defined(WIN32) || defined(__CYGWIN__)) && \ + !defined(USE_RECV_BEFORE_SEND_WORKAROUND) + printf("test requires recv-before-send workaround on Windows\n"); + return 1; /* skip since test will fail on Windows without workaround */ +#else + return 0; /* sure, run this! */ +#endif + } + pooh.readptr = data; pooh.sizeleft = strlen(data);