Artifactspublic-v0

curl

master
ply4 git calls49 ms289 KiB3 cachedprotocol v2
123 lines3.8 KiBRaw

NAME

curl_multi_perform - run all transfers until it would block

SYNOPSIS

c
#include <curl/curl.h>

CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);

DESCRIPTION

This function performs transfers on all the added handles that need attention in a non-blocking fashion. The easy handles have previously been added to the multi handle with curl_multi_add_handle(3).

When an application has found out there is data available for the multi_handle or a timeout has elapsed, the application should call this function to read/write whatever there is to read or write right now etc. curl_multi_perform(3) returns as soon as the reads/writes are done. This function does not require that there actually is any data available for reading or that data can be written, it can be called as a precaution. It stores the number of handles that still transfer data in the second argument's integer-pointer.

If the amount of running_handles is changed from the previous call (or is less than the amount of easy handles you have added to the multi handle), you know that there is one or more transfers less "running". You can then call curl_multi_info_read(3) to get information about each individual completed transfer, and that returned info includes CURLcode and more. If an added handle fails quickly, it may never be counted as a running_handle. You could use curl_multi_info_read(3) to track actual status of the added handles in that case.

CURLMOPT_NOTIFYFUNCTION(3) is an alternative to tracking running_handles where you register a callback to be notified when transfers are done and curl_multi_info_read(3) should be called.

When running_handles is set to zero (0) on the return of this function, there are no longer any transfers in progress.

When this function returns error, the state of all transfers are uncertain and they cannot be continued. curl_multi_perform(3) should not be called again on the same multi handle after an error has been returned, unless first removing all the handles and adding new ones.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  int still_running;
  CURLM *multi = curl_multi_init();
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_multi_add_handle(multi, curl);
    for(;;) {
      CURLMcode mresult = curl_multi_perform(multi, &still_running);
      if(mresult != CURLM_OK) {
        fprintf(stderr, "curl_multi_perform() failed, code %d.\n",
                (int)mresult);
        break;
      }

      if(!still_running) {
        break;
      }

      /* wait for activity, timeout or "nothing" */
      mresult = curl_multi_poll(multi, NULL, 0, 1000, NULL);
      if(mresult != CURLM_OK) {
        fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mresult);
        break;
      }
    } /* if there are still transfers, loop */
  }
}

%AVAILABILITY%

RETURN VALUE

This function returns a CURLMcode indicating success or error.

CURLM_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

This function returns errors regarding the whole multi stack. Problems on individual transfers may have occurred even when this function returns CURLM_OK. Use curl_multi_info_read(3) to figure out how individual transfers did.

TYPICAL USAGE

Most applications use curl_multi_poll(3) to make libcurl wait for activity on any of the ongoing transfers. As soon as one or more file descriptor has activity or the function times out, the application calls curl_multi_perform(3).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_multi_perform
5Section: 3
6Source: libcurl
7See-also:
8 - CURLMOPT_NOTIFYFUNCTION (3)
9 - curl_multi_add_handle (3)
10 - curl_multi_cleanup (3)
11 - curl_multi_fdset (3)
12 - curl_multi_info_read (3)
13 - curl_multi_init (3)
14 - curl_multi_wait (3)
15 - libcurl-errors (3)
16Protocol:
17 - All
18Added-in: 7.9.6
19---
21# NAME
23curl_multi_perform - run all transfers until it would block
25# SYNOPSIS
27~~~c
28#include <curl/curl.h>
30CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);
31~~~
33# DESCRIPTION
35This function performs transfers on all the added handles that need attention
36in a non-blocking fashion. The easy handles have previously been added to the
37multi handle with curl_multi_add_handle(3).
39When an application has found out there is data available for the multi_handle
40or a timeout has elapsed, the application should call this function to
41read/write whatever there is to read or write right now etc.
42curl_multi_perform(3) returns as soon as the reads/writes are done. This
43function does not require that there actually is any data available for
44reading or that data can be written, it can be called as a precaution. It
45stores the number of handles that still transfer data in the second argument's
46integer-pointer.
48If the amount of *running_handles* is changed from the previous call (or
49is less than the amount of easy handles you have added to the multi handle),
50you know that there is one or more transfers less "running". You can then call
51curl_multi_info_read(3) to get information about each individual
52completed transfer, and that returned info includes CURLcode and more. If an
53added handle fails quickly, it may never be counted as a running_handle. You
54could use curl_multi_info_read(3) to track actual status of the added
55handles in that case.
57CURLMOPT_NOTIFYFUNCTION(3) is an alternative to tracking *running_handles*
58where you register a callback to be notified when transfers are done and
59curl_multi_info_read(3) should be called.
61When *running_handles* is set to zero (0) on the return of this function,
62there are no longer any transfers in progress.
64When this function returns error, the state of all transfers are uncertain and
65they cannot be continued. curl_multi_perform(3) should not be called
66again on the same multi handle after an error has been returned, unless first
67removing all the handles and adding new ones.
69# %PROTOCOLS%
71# EXAMPLE
73~~~c
74int main(void)
76 int still_running;
77 CURLM *multi = curl_multi_init();
78 CURL *curl = curl_easy_init();
79 if(curl) {
80 curl_multi_add_handle(multi, curl);
81 for(;;) {
82 CURLMcode mresult = curl_multi_perform(multi, &still_running);
83 if(mresult != CURLM_OK) {
84 fprintf(stderr, "curl_multi_perform() failed, code %d.\n",
85 (int)mresult);
86 break;
87 }
89 if(!still_running) {
90 break;
91 }
93 /* wait for activity, timeout or "nothing" */
94 mresult = curl_multi_poll(multi, NULL, 0, 1000, NULL);
95 if(mresult != CURLM_OK) {
96 fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mresult);
97 break;
98 }
99 } /* if there are still transfers, loop */
100 }
102~~~
104# %AVAILABILITY%
106# RETURN VALUE
108This function returns a CURLMcode indicating success or error.
110CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
111libcurl-errors(3).
113This function returns errors regarding the whole multi stack. Problems on
114individual transfers may have occurred even when this function returns
115*CURLM_OK*. Use curl_multi_info_read(3) to figure out how individual transfers
116did.
118# TYPICAL USAGE
120Most applications use curl_multi_poll(3) to make libcurl wait for
121activity on any of the ongoing transfers. As soon as one or more file
122descriptor has activity or the function times out, the application calls
123curl_multi_perform(3).
Diagnostics4 git calls · 49 ms
CallStatusSizeTime049 ms
discover200152 B1 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=1
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 · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=25
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
fetch2001.7 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=22
git.response.bytes=1773
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=64ec10c0f4cd875f64fc9e19dea057c4d572c852
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=1773
git.pkt.payload.max=1752
git.sideband.band1.bytes=1751
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
a5e31928ed723e6e
Request
760ab218…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format