Artifactspublic-v0

curl

master
ply4 git calls27 ms288 KiB3 cachedprotocol v2
112 lines2.8 KiBRaw

NAME

curl_multi_waitfds - extract file descriptor information from a multi handle

SYNOPSIS

c
#include <curl/curl.h>
#include <stdlib.h>

CURLMcode curl_multi_waitfds(CURLM *multi,
                             struct curl_waitfd *ufds,
                             unsigned int size,
                             unsigned int *fd_count);

DESCRIPTION

This function extracts curl_waitfd structures which are similar to poll(2)'s pollfd structure from a given multi_handle.

These structures can be used for polling on multi_handle file descriptors in a fashion similar to curl_multi_poll(3). The curl_multi_perform(3) function should be called as soon as one of them is ready to be read from or written to.

libcurl fills provided ufds array up to the size. If a number of descriptors used by the multi_handle is greater than the size parameter then libcurl returns CURLM_OUT_OF_MEMORY error.

If the fd_count argument is not a null pointer, it points to a variable that on return specifies the number of descriptors used by the multi_handle to be checked for being ready to read or write.

The client code can pass size equal to zero to get the number of the descriptors and allocate appropriate storage for them to be used in a subsequent function call. In this case, fd_count receives a number greater than or equal to the number of descriptors.

%PROTOCOLS%

EXAMPLE

c
#include <stdlib.h>

int main(void)
{
  CURLMcode mresult;
  struct curl_waitfd *ufds;

  CURLM *multi = curl_multi_init();

  do {
    /* call curl_multi_perform() */

    /* get the count of file descriptors from the transfers */
    unsigned int fd_count = 0;

    mresult = curl_multi_waitfds(multi, NULL, 0, &fd_count);

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

    if(!fd_count)
      continue; /* no descriptors yet */

    /* allocate storage for our descriptors */
    ufds = malloc(fd_count * sizeof(struct curl_waitfd));

    /* get wait descriptors from the transfers and put them into array. */
    mresult = curl_multi_waitfds(multi, ufds, fd_count, &fd_count);

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

    /* Do polling on descriptors in ufds */

    free(ufds);
  } while(!mresult);
}

%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_waitfds
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_perform (3)
9 - curl_multi_poll (3)
10 - curl_multi_wait (3)
11 - curl_multi_fdset (3)
12Protocol:
13 - All
14Added-in: 8.8.0
15---
17# NAME
19curl_multi_waitfds - extract file descriptor information from a multi handle
21# SYNOPSIS
23~~~c
24#include <curl/curl.h>
25#include <stdlib.h>
27CURLMcode curl_multi_waitfds(CURLM *multi,
28 struct curl_waitfd *ufds,
29 unsigned int size,
30 unsigned int *fd_count);
31~~~
33# DESCRIPTION
35This function extracts *curl_waitfd* structures which are similar to
36*poll(2)*'s *pollfd* structure from a given multi_handle.
38These structures can be used for polling on multi_handle file descriptors in a
39fashion similar to curl_multi_poll(3). The curl_multi_perform(3)
40function should be called as soon as one of them is ready to be read from or
41written to.
43libcurl fills provided *ufds* array up to the *size*.
44If a number of descriptors used by the multi_handle is greater than the
45*size* parameter then libcurl returns CURLM_OUT_OF_MEMORY error.
47If the *fd_count* argument is not a null pointer, it points to a variable
48that on return specifies the number of descriptors used by the multi_handle to
49be checked for being ready to read or write.
51The client code can pass *size* equal to zero to get the number of the
52descriptors and allocate appropriate storage for them to be used in a
53subsequent function call. In this case, *fd_count* receives a number greater
54than or equal to the number of descriptors.
56# %PROTOCOLS%
58# EXAMPLE
60~~~c
61#include <stdlib.h>
63int main(void)
65 CURLMcode mresult;
66 struct curl_waitfd *ufds;
68 CURLM *multi = curl_multi_init();
70 do {
71 /* call curl_multi_perform() */
73 /* get the count of file descriptors from the transfers */
74 unsigned int fd_count = 0;
76 mresult = curl_multi_waitfds(multi, NULL, 0, &fd_count);
78 if(mresult != CURLM_OK) {
79 fprintf(stderr, "curl_multi_waitfds() failed, code %d.\n", mresult);
80 break;
81 }
83 if(!fd_count)
84 continue; /* no descriptors yet */
86 /* allocate storage for our descriptors */
87 ufds = malloc(fd_count * sizeof(struct curl_waitfd));
89 /* get wait descriptors from the transfers and put them into array. */
90 mresult = curl_multi_waitfds(multi, ufds, fd_count, &fd_count);
92 if(mresult != CURLM_OK) {
93 fprintf(stderr, "curl_multi_waitfds() failed, code %d.\n", mresult);
94 free(ufds);
95 break;
96 }
98 /* Do polling on descriptors in ufds */
100 free(ufds);
101 } while(!mresult);
103~~~
105# %AVAILABILITY%
107# RETURN VALUE
109This function returns a CURLMcode indicating success or error.
111CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
112libcurl-errors(3).
Diagnostics4 git calls · 27 ms
CallStatusSizeTime027 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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=3
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.3 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=21
git.response.bytes=1308
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=7a4dac894be0e509e831bbe88fe9b3bd36efcdb0
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=1308
git.pkt.payload.max=1287
git.sideband.band1.bytes=1286
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
a5e302817d977929
Request
3965cc70…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format