1curl_multi_wakeup(3) libcurl Manual curl_multi_wakeup(3)
2
3
4
6 curl_multi_wakeup - wakes up a sleeping curl_multi_poll call
7
9 #include <curl/curl.h>
10
11 CURLMcode curl_multi_wakeup(CURLM *multi_handle);
12
14 This function can be called from any thread and it wakes up a sleeping
15 curl_multi_poll(3) call that is currently (or will be) waiting for
16 activity or a timeout.
17
18 If the function is called when there is no curl_multi_poll(3) call, it
19 will cause the next call to return immediately.
20
21 Calling this function only guarantees to wake up the current (or the
22 next if there is no current) curl_multi_poll(3) call, which means it is
23 possible that multiple calls to this function will wake up the same
24 waiting operation.
25
26 This function has no effect on curl_multi_wait(3) calls.
27
29 CURLMcode type, general libcurl multi interface error code.
30
32 Added in 7.68.0
33
35 CURL *easy_handle;
36 CURLM *multi_handle;
37
38 /* add the individual easy handle */
39 curl_multi_add_handle(multi_handle, easy_handle);
40
41 /* this is thread 1 */
42 do {
43 CURLMcode mc;
44 int numfds;
45
46 mc = curl_multi_perform(multi_handle, &still_running);
47
48 if(mc == CURLM_OK) {
49 /* wait for activity, timeout or wakeup */
50 mc = curl_multi_poll(multi_handle, NULL, 0, 10000, &numfds);
51 }
52
53 if(time_to_die())
54 exit(1);
55
56 } while(still_running);
57
58 curl_multi_remove_handle(multi_handle, easy_handle);
59
60 /* this is thread 2 */
61
62 if(something makes us decide to stop thread 1) {
63
64 set_something_to_signal_thread_1_to_exit();
65
66 curl_multi_wakeup(multi_handle);
67 }
68
69
71 curl_multi_poll(3), curl_multi_wait(3)
72
73
74
75libcurl 7.71.1 November 25, 2019 curl_multi_wakeup(3)