Dnia 2021-06-18, o godz. 23:53:57 Daniel Stenberg <dan...@haxx.se> napisaĆ(a):
> On Fri, 18 Jun 2021, Firefox OS via curl-library wrote: > > > Do you mean imap://...? Yes, it does. And the callstack looks the > > same. > > I cannot reproduce. I converted "curl_imap_teardown_issue.c" into > test case 677 in this commit: > https://github.com/curl/curl/commit/4401aede3133d1db9e3cc907b3c6640eda06c57a > > You can check out this branch: > https://github.com/curl/curl/tree/bagder/multi_cleanup-imap-test > > And if you build the code and the tests run 677 like: > > cd tests && make -sj7 && ./runtests.pl 677 > > Can you figure out what we need to change to make lib677.c hang? > Thanks for creating a test case. The problem cannot be directly reproduced using curl test suite because ftpserver.pl doesn't support IMAP IDLE mode (RFC2177). Please have a look at repro1.patch which adds very limited support of idle mode to ftpserver.pl (so that idle mode can be entered but not exited). The result is now the same as I observe using a real IMAP server: ---cut here--- test 0677...[IMAP with CONNECT_ONLY, custom command then exit] --p----e-v- OK (1 out of 1 , remaining: 00:00, took 126.621s, duration: 02:06) TESTDONE: 1 tests were considered during 127 seconds. TESTDONE: 1 tests out of 1 reported OK: 100% ---cut here--- (Please also note that I replaced A1 IDLE\n with A1 IDLE\r\n because ftpserver.pl doesn't seem to accept commands terminated with just \n, contrary to the server I used before.) What I wasn't aware of before I saw your test677 file is that after libcurl "finishes" CONNECT_ONLY connection and passes ACTIVE_SOCKET to the application, it still wants to proceed with A002 LOGOUT command (waiting for a "correct" answer) despite it has no idea what the state of the connection can be and what the server will do after receiving such string. Since the responsibility for the conversation has been already transferred to the application, I expect libcurl to avoid sending anything. I expressed this in repro2.patch (forget about repro1.patch) and now, without touching ftpserver.pl, the result is as follows: ---cut here--- test 0677...[IMAP with CONNECT_ONLY, custom command then exit] 677: protocol FAILED: --- log/check-expected 2021-06-22 17:30:42.767593317 +0200 +++ log/check-generated 2021-06-22 17:30:42.767593317 +0200 @@ -1,2 +1,3 @@ A001 CAPABILITY[CR][LF] A1 IDLE[CR][LF] +A002 LOGOUT[CR][LF] - abort tests TESTDONE: 1 tests were considered during 7 seconds. TESTDONE: 0 tests out of 1 reported OK: 0% TESTFAIL: These test cases failed: 677 ---cut here---
diff --git a/tests/data/test677 b/tests/data/test677 index 15526a67e..3f84dce81 100644 --- a/tests/data/test677 +++ b/tests/data/test677 @@ -37,7 +37,7 @@ imap://%HOSTIP:%IMAPPORT/677 <verify> <protocol> A001 CAPABILITY -A1 IDLE +A1 IDLE A002 LOGOUT </protocol> </verify> diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 9040478ec..6db38e1e8 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -643,6 +643,7 @@ sub protocolsetup { 'STATUS' => \&STATUS_imap, 'STORE' => \&STORE_imap, 'UID' => \&UID_imap, + 'IDLE' => \&IDLE_imap, ); %displaytext = ( 'welcome' => join("", @@ -1587,6 +1588,16 @@ sub COPY_imap { return 0; } +sub IDLE_imap { + logmsg "IDLE_imap\n"; + + sendcontrol "+ entering idle mode\r\n"; + %commandfunc = (); + $proto = "imap-idle"; + + return 0; +} + sub UID_imap { my ($args) = @_; my ($command) = split(/ /, $args, 1); @@ -3217,7 +3228,9 @@ while(1) { } } else { - sendcontrol "500 Unrecognized command\r\n"; + if ($proto ne "imap-idle") { + sendcontrol "500 Unrecognized command\r\n"; + } last; } diff --git a/tests/libtest/lib677.c b/tests/libtest/lib677.c index 74675c882..316ddc988 100644 --- a/tests/libtest/lib677.c +++ b/tests/libtest/lib677.c @@ -25,7 +25,7 @@ #include "warnless.h" #include "memdebug.h" -static const char cmd[] = "A1 IDLE\n"; +static const char cmd[] = "A1 IDLE\r\n"; static char buf[1024]; int test(char *URL)
diff --git a/tests/data/test677 b/tests/data/test677 index 15526a67e..e3d9041fd 100644 --- a/tests/data/test677 +++ b/tests/data/test677 @@ -37,8 +37,7 @@ imap://%HOSTIP:%IMAPPORT/677 <verify> <protocol> A001 CAPABILITY -A1 IDLE -A002 LOGOUT +A1 IDLE </protocol> </verify> </testcase> diff --git a/tests/libtest/lib677.c b/tests/libtest/lib677.c index 74675c882..316ddc988 100644 --- a/tests/libtest/lib677.c +++ b/tests/libtest/lib677.c @@ -25,7 +25,7 @@ #include "warnless.h" #include "memdebug.h" -static const char cmd[] = "A1 IDLE\n"; +static const char cmd[] = "A1 IDLE\r\n"; static char buf[1024]; int test(char *URL)
------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html