Artifactspublic-v0

curl

master
ply4 git calls30 ms289 KiB3 cachedprotocol v2
142 lines4.7 KiBRaw

NAME

curl_easy_pause - pause and unpause a connection

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_pause(CURL *handle, int action);

DESCRIPTION

Using this function, you can explicitly mark a running connection to get paused, and you can unpause a connection that was previously paused. Unlike most other libcurl functions, curl_easy_pause(3) can be used from within all callbacks except the socket callback set with CURLMOPT_SOCKETFUNCTION(3).

A connection can be paused by using this function or by letting the read or the write callbacks return the proper return code (CURL_READFUNC_PAUSE and CURL_WRITEFUNC_PAUSE). A write callback that returns pause signals to the library that it could not take care of any data at all, and that data is then delivered again to the callback when the transfer is unpaused.

While it may feel tempting, take care and notice that you cannot call this function from another thread. To unpause, you may for example call it from the progress callback (CURLOPT_PROGRESSFUNCTION(3)).

When this function is called to unpause receiving, the write callback might get called before this function returns to deliver cached content. When libcurl delivers such cached data to the write callback, it is delivered as fast as possible, which may overstep the boundary set in CURLOPT_MAX_RECV_SPEED_LARGE(3) etc.

The handle argument identifies the transfer you want to pause or unpause.

A paused transfer is excluded from low speed cancels via the CURLOPT_LOW_SPEED_LIMIT(3) option and unpausing a transfer resets the time period required for the low speed limit to be met.

The action argument is a set of bits that sets the new state of the connection. The following bits can be used:

CURLPAUSE_RECV

Pause receiving data. There is no data received on this connection until this function is called again without this bit set. Thus, the write callback (CURLOPT_WRITEFUNCTION(3)) is not called.

CURLPAUSE_SEND

Pause sending data. There is no data sent on this connection until this function is called again without this bit set. Thus, the read callback (CURLOPT_READFUNCTION(3)) is not called.

CURLPAUSE_ALL

Convenience define that pauses both directions.

CURLPAUSE_CONT

Convenience define that unpauses both directions.

LIMITATIONS

The pausing of transfers does not work with protocols that work without network connectivity, like file://. Trying to pause such a transfer, in any direction, might cause problems or error.

MULTIPLEXED

On multiplexed connections (HTTP/2 or HTTP/3), pausing an individual stream while others remain active forces libcurl to buffer up to 10 MB of data for the paused transfer. Because libcurl must continuously drain the shared socket to sustain active streams, and the default flow-control window allows the server to send up to 10 MB before halting, libcurl is forced to buffer the incoming bytes in memory.

When such a paused stream is unpaused again, any buffered data is delivered first.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    /* pause a transfer in both directions */
    curl_easy_pause(curl, CURLPAUSE_RECV | CURLPAUSE_SEND);
  }
}

MEMORY USE

When pausing a download transfer by returning the appropriate return code from a write callback, the read data is already in libcurl's internal buffers so it has to keep it in an allocated buffer until the receiving is again unpaused using this function.

If the downloaded data is compressed and is asked to get uncompressed automatically on download, libcurl continues to uncompress the entire downloaded chunk and it caches the data uncompressed. This has the side- effect that if you download something that is compressed a lot, it can result in a large data amount needing to be allocated to save the data during the pause. Consider not using paused receiving if you allow libcurl to uncompress data automatically.

If the download is done with HTTP/2 or HTTP/3, there is up to a stream window size worth of data that curl cannot stop but instead needs to cache while the transfer is paused. This means that if a window size of 64 MB is used, libcurl might end up having to cache 64 MB of data.

%AVAILABILITY%

RETURN VALUE

This function returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) there can be an error message stored in the error buffer when non-zero is returned.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_easy_pause
5Section: 3
6Source: libcurl
7See-also:
8 - curl_easy_cleanup (3)
9 - curl_easy_reset (3)
10Protocol:
11 - All
12Added-in: 7.18.0
13---
15# NAME
17curl_easy_pause - pause and unpause a connection
19# SYNOPSIS
21~~~c
22#include <curl/curl.h>
24CURLcode curl_easy_pause(CURL *handle, int action);
25~~~
27# DESCRIPTION
29Using this function, you can explicitly mark a running connection to get
30paused, and you can unpause a connection that was previously paused. Unlike
31most other libcurl functions, curl_easy_pause(3) can be used from within all
32callbacks except the socket callback set with CURLMOPT_SOCKETFUNCTION(3).
34A connection can be paused by using this function or by letting the read or
35the write callbacks return the proper return code (*CURL_READFUNC_PAUSE* and
36*CURL_WRITEFUNC_PAUSE*). A write callback that returns pause signals to the
37library that it could not take care of any data at all, and that data is then
38delivered again to the callback when the transfer is unpaused.
40While it may feel tempting, take care and notice that you cannot call this
41function from another thread. To unpause, you may for example call it from the
42progress callback (CURLOPT_PROGRESSFUNCTION(3)).
44When this function is called to unpause receiving, the write callback might
45get called before this function returns to deliver cached content. When
46libcurl delivers such cached data to the write callback, it is delivered as
47fast as possible, which may overstep the boundary set in
48CURLOPT_MAX_RECV_SPEED_LARGE(3) etc.
50The **handle** argument identifies the transfer you want to pause or
51unpause.
53A paused transfer is excluded from low speed cancels via the
54CURLOPT_LOW_SPEED_LIMIT(3) option and unpausing a transfer resets the
55time period required for the low speed limit to be met.
57The **action** argument is a set of bits that sets the new state of the
58connection. The following bits can be used:
60## CURLPAUSE_RECV
62Pause receiving data. There is no data received on this connection until this
63function is called again without this bit set. Thus, the write callback
64(CURLOPT_WRITEFUNCTION(3)) is not called.
66## CURLPAUSE_SEND
68Pause sending data. There is no data sent on this connection until this
69function is called again without this bit set. Thus, the read callback
70(CURLOPT_READFUNCTION(3)) is not called.
72## CURLPAUSE_ALL
74Convenience define that pauses both directions.
76## CURLPAUSE_CONT
78Convenience define that unpauses both directions.
80# LIMITATIONS
82The pausing of transfers does not work with protocols that work without
83network connectivity, like `file://`. Trying to pause such a transfer, in any
84direction, might cause problems or error.
86# MULTIPLEXED
88On multiplexed connections (HTTP/2 or HTTP/3), pausing an individual stream
89while others remain active forces libcurl to buffer up to 10 MB of data for
90the paused transfer. Because libcurl must continuously drain the shared socket
91to sustain active streams, and the default flow-control window allows the
92server to send up to 10 MB before halting, libcurl is forced to buffer the
93incoming bytes in memory.
95When such a paused stream is unpaused again, any buffered data is delivered
96first.
98# %PROTOCOLS%
100# EXAMPLE
102~~~c
103int main(void)
105 CURL *curl = curl_easy_init();
106 if(curl) {
107 /* pause a transfer in both directions */
108 curl_easy_pause(curl, CURLPAUSE_RECV | CURLPAUSE_SEND);
109 }
111~~~
113# MEMORY USE
115When pausing a download transfer by returning the appropriate return code from
116a write callback, the read data is already in libcurl's internal buffers so it
117has to keep it in an allocated buffer until the receiving is again unpaused
118using this function.
120If the downloaded data is compressed and is asked to get uncompressed
121automatically on download, libcurl continues to uncompress the entire
122downloaded chunk and it caches the data uncompressed. This has the side-
123effect that if you download something that is compressed a lot, it can result
124in a large data amount needing to be allocated to save the data during the
125pause. Consider not using paused receiving if you allow libcurl to uncompress
126data automatically.
128If the download is done with HTTP/2 or HTTP/3, there is up to a stream window
129size worth of data that curl cannot stop but instead needs to cache while the
130transfer is paused. This means that if a window size of 64 MB is used, libcurl
131might end up having to cache 64 MB of data.
133# %AVAILABILITY%
135# RETURN VALUE
137This function returns a CURLcode indicating success or error.
139CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
140libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
141there can be an error message stored in the error buffer when non-zero is
142returned.
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=23
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.2 KiB · hit26 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2245
git.response.cache=HIT
git.response.duration_ms=26
git.fetch.wants=f0c9230da5fdb311432b30197f3d11ce972460b0
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2245
git.pkt.payload.max=2224
git.sideband.band1.bytes=2223
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e30a52fe19ee28
Request
68a721d1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format