1CURLMOPT_TIMERDATA(3) curl_multi_setopt options CURLMOPT_TIMERDATA(3)
2
3
4
6 CURLMOPT_TIMERDATA - custom pointer to pass to timer callback
7
9 #include <curl/curl.h>
10
11 CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer);
12
14 A data pointer to pass to the timer callback set with the CURL‐
15 MOPT_TIMERFUNCTION(3) option.
16
17 This pointer will not be touched by libcurl but will only be passed in
18 to the timer callbacks's userp argument.
19
21 NULL
22
24 All
25
27 static gboolean timeout_cb(gpointer user_data)
28 {
29 int running;
30 if(user_data) {
31 g_free(user_data);
32 curl_multi_setopt(curl_handle, CURLMOPT_TIMERDATA, NULL);
33 }
34 curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running);
35 return G_SOURCE_REMOVE;
36 }
37
38 static int timerfunc(CURLM *multi, long timeout_ms, void *userp)
39 {
40 guint *id = userp;
41
42 if(id)
43 g_source_remove(*id);
44
45 /* -1 means we should just delete our timer. */
46 if(timeout_ms == -1) {
47 g_free(id);
48 id = NULL;
49 }
50 else {
51 if(!id)
52 id = g_new(guint, 1);
53 *id = g_timeout_add(timeout_ms, timeout_cb, id);
54 }
55 curl_multi_setopt(multi, CURLMOPT_TIMERDATA, id);
56 return 0;
57 }
58
59 curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
60
62 Added in 7.16.0
63
65 Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION
66 if not.
67
69 CURLMOPT_TIMERFUNCTION(3), CURLMOPT_SOCKETFUNCTION(3),
70
71
72
73libcurl 7.69.1 May 27, 2017 CURLMOPT_TIMERDATA(3)