Artifactspublic-v0

curl

master
ply4 git calls348 ms289 KiB2 cachedprotocol v2
150 lines4.0 KiBRaw

NAME

curl_multi_poll - poll on all easy handles in a multi handle

SYNOPSIS

c
#include <curl/curl.h>

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

DESCRIPTION

curl_multi_poll(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 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.

The curl_multi_wakeup(3) function can be used from another thread to wake up this function and return faster. This is one of the details that makes this function different than curl_multi_wait(3) which cannot be woken up this way.

If no extra file descriptors are provided and libcurl has no file descriptor to offer to wait for, this function instead waits during timeout_ms milliseconds (or shorter if an internal timer indicates so). This is the other detail that makes this function different than curl_multi_wait(3).

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
extern void handle_fd(int);

int main(void)
{
  CURL *easy_handle;
  CURLM *multi_handle;
  int still_running = 0;
  int myfd = 2; /* this is our own file descriptor */

  multi_handle = curl_multi_init();
  easy_handle = curl_easy_init();

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

  do {
    CURLMcode mresult;
    int numfds;

    mresult = curl_multi_perform(multi_handle, &still_running);

    if(mresult == CURLM_OK) {
      struct curl_waitfd myown;
      myown.fd = myfd;
      myown.events = CURL_WAIT_POLLIN; /* wait for input */
      myown.revents = 0; /* clear it */

      /* wait for activity on curl's descriptors or on our own,
         or timeout */
      mresult = curl_multi_poll(multi_handle, &myown, 1, 1000, &numfds);

      if(myown.revents) {
        /* did our descriptor receive an event? */
        handle_fd(myfd);
      }
    }

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

  } while(still_running);

  curl_multi_remove_handle(multi_handle, easy_handle);
}

%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_poll
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_fdset (3)
9 - curl_multi_perform (3)
10 - curl_multi_wait (3)
11 - curl_multi_wakeup (3)
12Protocol:
13 - All
14Added-in: 7.66.0
15---
17# NAME
19curl_multi_poll - poll on all easy handles in a multi handle
21# SYNOPSIS
23~~~c
24#include <curl/curl.h>
26CURLMcode curl_multi_poll(CURLM *multi_handle,
27 struct curl_waitfd extra_fds[],
28 unsigned int extra_nfds,
29 int timeout_ms,
30 int *numfds);
31~~~
33# DESCRIPTION
35curl_multi_poll(3) polls all file descriptors used by the curl easy
36handles contained in the given multi handle set. It blocks until activity is
37detected on at least one of the handles or *timeout_ms* has passed.
38Alternatively, if the multi handle has a pending internal timeout that has a
39shorter expiry time than *timeout_ms*, that shorter time is used instead
40to make sure timeout accuracy is reasonably kept.
42The calling application may pass additional curl_waitfd structures which are
43similar to *poll(2)*'s *pollfd* structure to be waited on in the same
44call.
46On completion, if *numfds* is non-NULL, it gets populated with the total
47number of file descriptors on which interesting events occurred. This number
48can include both libcurl internal descriptors as well as descriptors provided
49in *extra_fds*.
51The curl_multi_wakeup(3) function can be used from another thread to
52wake up this function and return faster. This is one of the details
53that makes this function different than curl_multi_wait(3) which cannot
54be woken up this way.
56If no extra file descriptors are provided and libcurl has no file descriptor
57to offer to wait for, this function instead waits during *timeout_ms*
58milliseconds (or shorter if an internal timer indicates so). This is the other
59detail that makes this function different than curl_multi_wait(3).
61This function is encouraged to be used instead of select(3) when using the
62multi interface to allow applications to easier circumvent the common problem
63with 1024 maximum file descriptors.
65# curl_waitfd
67~~~c
68struct curl_waitfd {
69 curl_socket_t fd;
70 short events;
71 short revents;
72};
73~~~
75## CURL_WAIT_POLLIN
77Bit flag to curl_waitfd.events indicating the socket should poll on read
78events such as new data received.
80## CURL_WAIT_POLLPRI
82Bit flag to curl_waitfd.events indicating the socket should poll on high
83priority read events such as out of band data.
85## CURL_WAIT_POLLOUT
87Bit flag to curl_waitfd.events indicating the socket should poll on write
88events such as the socket being clear to write without blocking.
90# %PROTOCOLS%
92# EXAMPLE
94~~~c
95extern void handle_fd(int);
97int main(void)
99 CURL *easy_handle;
100 CURLM *multi_handle;
101 int still_running = 0;
102 int myfd = 2; /* this is our own file descriptor */
104 multi_handle = curl_multi_init();
105 easy_handle = curl_easy_init();
107 /* add the individual easy handle */
108 curl_multi_add_handle(multi_handle, easy_handle);
110 do {
111 CURLMcode mresult;
112 int numfds;
114 mresult = curl_multi_perform(multi_handle, &still_running);
116 if(mresult == CURLM_OK) {
117 struct curl_waitfd myown;
118 myown.fd = myfd;
119 myown.events = CURL_WAIT_POLLIN; /* wait for input */
120 myown.revents = 0; /* clear it */
122 /* wait for activity on curl's descriptors or on our own,
123 or timeout */
124 mresult = curl_multi_poll(multi_handle, &myown, 1, 1000, &numfds);
126 if(myown.revents) {
127 /* did our descriptor receive an event? */
128 handle_fd(myfd);
129 }
130 }
132 if(mresult != CURLM_OK) {
133 fprintf(stderr, "curl_multi failed, code %d.\n", mresult);
134 break;
135 }
137 } while(still_running);
139 curl_multi_remove_handle(multi_handle, easy_handle);
141~~~
143# %AVAILABILITY%
145# RETURN VALUE
147This function returns a CURLMcode indicating success or error.
149CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
150libcurl-errors(3).
Diagnostics4 git calls · 348 ms
CallStatusSizeTime0348 ms
discover200152 B3 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 · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=340
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=5
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 KiB340 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1791
git.response.cache=MISS
git.response.duration_ms=340
git.fetch.wants=8c2488feb33cb1f554f058e34381c692b37e66c1
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=1791
git.pkt.payload.max=1770
git.sideband.band1.bytes=1769
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
a5e30a93c9a9ee28
Request
2441b89e…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format