Artifactspublic-v0

curl

master
ply4 git calls367 ms288 KiB2 cachedprotocol v2
128 lines3.2 KiBRaw

NAME

curl_multi_wait - poll on all easy handles in a multi handle

SYNOPSIS

c
#include <curl/curl.h>

CURLMcode curl_multi_wait(CURLM *multi_handle,
                          struct curl_waitfd extra_fds[],
                          unsigned int extra_nfds,
                          int timeout_ms,
                          int *numfds);

DESCRIPTION

curl_multi_wait(3) polls all file descriptors used by the curl easy handles contained in the given multi handle set. It blocks until activity is detected on at least one of the handles or timeout_ms has passed. Alternatively, if the multi handle has a pending internal timeout that has a shorter expiry time than timeout_ms, that shorter time is being used instead to make sure timeout accuracy is reasonably kept.

The calling application may pass additional curl_waitfd structures which are similar to poll(2)'s pollfd structure to be waited on in the same call.

On completion, if numfds is non-NULL, it gets populated with the total number of file descriptors on which interesting events occurred. This number can include both libcurl internal descriptors as well as descriptors provided in extra_fds.

If no extra file descriptors are provided and libcurl has no file descriptor to offer to wait for, this function returns immediately. (Consider using curl_multi_poll(3) to avoid this behavior.)

This function is encouraged to be used instead of select(3) when using the multi interface to allow applications to easier circumvent the common problem with 1024 maximum file descriptors.

curl_waitfd

c
struct curl_waitfd {
  curl_socket_t fd;
  short events;
  short revents;
};

CURL_WAIT_POLLIN

Bit flag to curl_waitfd.events indicating the socket should poll on read events such as new data received.

CURL_WAIT_POLLPRI

Bit flag to curl_waitfd.events indicating the socket should poll on high priority read events such as out of band data.

CURL_WAIT_POLLOUT

Bit flag to curl_waitfd.events indicating the socket should poll on write events such as the socket being clear to write without blocking.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *easy;
  CURLM *multi = curl_multi_init();
  int still_running;

  easy = curl_easy_init();

  /* add the individual easy handle */
  curl_multi_add_handle(multi, easy);

  do {
    CURLMcode mresult;
    int numfds;

    mresult = curl_multi_perform(multi, &still_running);

    if(mresult == CURLM_OK) {
      /* wait for activity, timeout or "nothing" */
      mresult = curl_multi_wait(multi, NULL, 0, 1000, &numfds);
    }

    if(mresult != CURLM_OK) {
      fprintf(stderr, "curl_multi failed, code %d.\n", mresult);
      break;
    }

  } while(still_running);

  curl_multi_remove_handle(multi, easy);
}

%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).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_multi_wait
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_fdset (3)
9 - curl_multi_perform (3)
10 - curl_multi_poll (3)
11Protocol:
12 - All
13Added-in: 7.28.0
14---
16# NAME
18curl_multi_wait - poll on all easy handles in a multi handle
20# SYNOPSIS
22~~~c
23#include <curl/curl.h>
25CURLMcode curl_multi_wait(CURLM *multi_handle,
26 struct curl_waitfd extra_fds[],
27 unsigned int extra_nfds,
28 int timeout_ms,
29 int *numfds);
30~~~
32# DESCRIPTION
34curl_multi_wait(3) polls all file descriptors used by the curl easy
35handles contained in the given multi handle set. It blocks until activity is
36detected on at least one of the handles or *timeout_ms* has passed.
37Alternatively, if the multi handle has a pending internal timeout that has a
38shorter expiry time than *timeout_ms*, that shorter time is being used
39instead to make sure timeout accuracy is reasonably kept.
41The calling application may pass additional *curl_waitfd* structures which
42are similar to *poll(2)*'s *pollfd* structure to be waited on in the
43same call.
45On completion, if *numfds* is non-NULL, it gets populated with the total
46number of file descriptors on which interesting events occurred. This number
47can include both libcurl internal descriptors as well as descriptors provided
48in *extra_fds*.
50If no extra file descriptors are provided and libcurl has no file descriptor
51to offer to wait for, this function returns immediately. (Consider using
52curl_multi_poll(3) to avoid this behavior.)
54This function is encouraged to be used instead of select(3) when using the
55multi interface to allow applications to easier circumvent the common problem
56with 1024 maximum file descriptors.
58# curl_waitfd
60~~~c
61struct curl_waitfd {
62 curl_socket_t fd;
63 short events;
64 short revents;
65};
66~~~
68## CURL_WAIT_POLLIN
70Bit flag to *curl_waitfd.events* indicating the socket should poll on read
71events such as new data received.
73## CURL_WAIT_POLLPRI
75Bit flag to *curl_waitfd.events* indicating the socket should poll on high
76priority read events such as out of band data.
78## CURL_WAIT_POLLOUT
80Bit flag to *curl_waitfd.events* indicating the socket should poll on
81write events such as the socket being clear to write without blocking.
83# %PROTOCOLS%
85# EXAMPLE
87~~~c
88int main(void)
90 CURL *easy;
91 CURLM *multi = curl_multi_init();
92 int still_running;
94 easy = curl_easy_init();
96 /* add the individual easy handle */
97 curl_multi_add_handle(multi, easy);
99 do {
100 CURLMcode mresult;
101 int numfds;
103 mresult = curl_multi_perform(multi, &still_running);
105 if(mresult == CURLM_OK) {
106 /* wait for activity, timeout or "nothing" */
107 mresult = curl_multi_wait(multi, NULL, 0, 1000, &numfds);
108 }
110 if(mresult != CURLM_OK) {
111 fprintf(stderr, "curl_multi failed, code %d.\n", mresult);
112 break;
113 }
115 } while(still_running);
117 curl_multi_remove_handle(multi, easy);
119~~~
121# %AVAILABILITY%
123# RETURN VALUE
125This function returns a CURLMcode indicating success or error.
127CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
128libcurl-errors(3).
Diagnostics4 git calls · 367 ms
CallStatusSizeTime0367 ms
discover200152 B5 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=359
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
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.5 KiB359 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1530
git.response.cache=MISS
git.response.duration_ms=359
git.fetch.wants=f9a7b7b6444fa628afbe359f4a8991a19c3dd8df
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=1530
git.pkt.payload.max=1509
git.sideband.band1.bytes=1508
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
a5e1dfccbf7fd96e
Request
50fb3a29…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format