1curl_easy_pause(3) libcurl Manual curl_easy_pause(3)
2
3
4
6 curl_easy_pause - pause and unpause a connection
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_pause(CURL *handle, int bitmask );
12
13
15 Using this function, you can explicitly mark a running connection to
16 get paused, and you can unpause a connection that was previously
17 paused.
18
19 A connection can be paused by using this function or by letting the
20 read or the write callbacks return the proper magic return code
21 (CURL_READFUNC_PAUSE and CURL_WRITEFUNC_PAUSE). A write callback that
22 returns pause signals to the library that it couldn't take care of any
23 data at all, and that data will then be delivered again to the callback
24 when the writing is later unpaused.
25
26 While it may feel tempting, take care and notice that you cannot call
27 this function from another thread. To unpause, you may for example call
28 it from the progress callback (CURLOPT_PROGRESSFUNCTION(3)), which gets
29 called at least once per second, even if the connection is paused.
30
31 When this function is called to unpause reading, the chance is high
32 that you will get your write callback called before this function
33 returns.
34
35 The handle argument is of course identifying the handle that operates
36 on the connection you want to pause or unpause.
37
38 The bitmask argument is a set of bits that sets the new state of the
39 connection. The following bits can be used:
40
41 CURLPAUSE_RECV
42 Pause receiving data. There will be no data received on this
43 connection until this function is called again without this bit
44 set. Thus, the write callback (CURLOPT_WRITEFUNCTION(3)) won't
45 be called.
46
47 CURLPAUSE_SEND
48 Pause sending data. There will be no data sent on this connec‐
49 tion until this function is called again without this bit set.
50 Thus, the read callback (CURLOPT_READFUNCTION(3)) won't be
51 called.
52
53 CURLPAUSE_ALL
54 Convenience define that pauses both directions.
55
56 CURLPAUSE_CONT
57 Convenience define that unpauses both directions.
58
60 CURLE_OK (zero) means that the option was set properly, and a non-zero
61 return code means something wrong occurred after the new state was set.
62 See the libcurl-errors(3) man page for the full list with descriptions.
63
65 The pausing of transfers does not work with protocols that work without
66 network connectivity, like FILE://. Trying to pause such a transfer, in
67 any direction, will cause problems in the worst case or an error in the
68 best case.
69
71 This function was added in libcurl 7.18.0. Before this version, there
72 was no explicit support for pausing transfers.
73
75 Before libcurl 7.32.0, when a specific handle was unpaused with this
76 function, there was no particular forced rechecking or similar of the
77 socket's state, which made the continuation of the transfer get delayed
78 until next multi-socket call invoke or even longer. Alternatively, the
79 user could forcibly call for example curl_multi_socket_all(3) - with a
80 rather hefty performance penalty.
81
82 Starting in libcurl 7.32.0, unpausing a transfer will schedule a time‐
83 out trigger for that handle 1 millisecond into the future, so that a
84 curl_multi_socket_action( ... CURL_SOCKET_TIMEOUT) can be used immedi‐
85 ately afterwards to get the transfer going again as desired.
86
88 When pausing a read by returning the magic return code from a write
89 callback, the read data is already in libcurl's internal buffers so
90 it'll have to keep it in an allocated buffer until the reading is again
91 unpaused using this function.
92
93 If the downloaded data is compressed and is asked to get uncompressed
94 automatically on download, libcurl will continue to uncompress the
95 entire downloaded chunk and it will cache the data uncompressed. This
96 has the side- effect that if you download something that is compressed
97 a lot, it can result in a very large data amount needing to be allo‐
98 cated to save the data during the pause. This said, you should probably
99 consider not using paused reading if you allow libcurl to uncompress
100 data automatically.
101
103 curl_easy_cleanup(3), curl_easy_reset(3)
104
105
106
107libcurl 7.66.0 May 01, 2016 curl_easy_pause(3)