From f3c35e371cc70f1b6bc33f7faa904d37d1567eb3 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 17 Nov 2019 15:12:15 +0100 Subject: multi: add curl_multi_wakeup() This commit adds curl_multi_wakeup() which was previously in the TODO list under the curl_multi_unblock name. On some platforms and with some configurations this feature might not be available or can fail, in these cases a new error code (CURLM_WAKEUP_FAILURE) is returned from curl_multi_wakeup(). Fixes #4418 Closes #4608 --- tests/libtest/test.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/libtest/test.h') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index bb1acca0e..3c8323de4 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -355,6 +355,60 @@ extern int unitfail; /* ---------------------------------------------------------------- */ +#define exe_multi_poll(A,B,C,D,E,Y,Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_poll((A), (B), (C), (D), (E))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_poll() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ + else if(*((E)) < 0) { \ + fprintf(stderr, "%s:%d curl_multi_poll() succeeded, " \ + "but returned invalid numfds value (%d)\n", \ + (Y), (Z), (int)*((E))); \ + res = TEST_ERR_NUM_HANDLES; \ + } \ +} WHILE_FALSE + +#define res_multi_poll(A, B, C, D, E) \ + exe_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + +#define chk_multi_poll(A, B, C, D, E, Y, Z) do { \ + exe_multi_poll((A), (B), (C), (D), (E), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ +} WHILE_FALSE + +#define multi_poll(A, B, C, D, E) \ + chk_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + +/* ---------------------------------------------------------------- */ + +#define exe_multi_wakeup(A,Y,Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_wakeup((A))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_wakeup() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ +} WHILE_FALSE + +#define res_multi_wakeup(A) \ + exe_multi_wakeup((A), (__FILE__), (__LINE__)) + +#define chk_multi_wakeup(A, Y, Z) do { \ + exe_multi_wakeup((A), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ +} WHILE_FALSE + +#define multi_wakeup(A) \ + chk_multi_wakeup((A), (__FILE__), (__LINE__)) + +/* ---------------------------------------------------------------- */ + #define exe_select_test(A, B, C, D, E, Y, Z) do { \ int ec; \ if(select_wrapper((A), (B), (C), (D), (E)) == -1) { \ -- cgit v1.2.3