Artifactspublic-v0

curl

master
ply4 git calls164 ms288 KiB2 cachedprotocol v2
105 lines2.9 KiBRaw

NAME

curl_multi_info_read - read multi stack information

SYNOPSIS

c
#include <curl/curl.h>

CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue);

DESCRIPTION

Ask the multi handle if there are any messages from the individual transfers. Messages may include information such as an error code from the transfer or the fact that a transfer is completed. More details on these should be written down as well.

Repeated calls to this function returns a new struct each time, until a NULL is returned as a signal that there is no more to get at this point. The integer pointed to with msgs_in_queue contains the number of remaining messages after this function was called.

When you fetch a message using this function, it is removed from the internal queue so calling this function again does not return the same message again. It instead returns new messages at each new invoke until the queue is emptied.

WARNING: The data the returned pointer points to does not survive calling curl_multi_cleanup(3), curl_multi_remove_handle(3) or curl_easy_cleanup(3).

The CURLMsg struct is simple and only contains basic information. If more involved information is wanted, the particular "easy handle" is present in that struct and can be used in subsequent regular curl_easy_getinfo(3) calls (or similar):

c
struct CURLMsg {
  CURLMSG msg;       /* what this message means */
  CURL *easy_handle; /* the handle it concerns */
  union {
    void *whatever;    /* message-specific data */
    CURLcode result;   /* return code for transfer */
  } data;
};

When msg is CURLMSG_DONE, the message identifies a transfer that is done, and then result contains the return code for the easy handle that completed.

At this point, there are no other msg types defined.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURLM *multi = curl_multi_init();
  CURL *curl = curl_easy_init();
  if(curl) {
    struct CURLMsg *m;

    /* call curl_multi_perform or curl_multi_socket_action first, then loop
       through and check if there are any transfers that have completed */

    do {
      int msgq = 0;
      m = curl_multi_info_read(multi, &msgq);
      if(m && (m->msg == CURLMSG_DONE)) {
        CURL *e = m->easy_handle;
        /* m->data.result holds the error code for the transfer */
        curl_multi_remove_handle(multi, e);
        curl_easy_cleanup(e);
      }
    } while(m);
  }
}

%AVAILABILITY%

RETURN VALUE

A pointer to a filled-in struct, or NULL if it failed or ran out of structs. It also writes the number of messages left in the queue (after this read) in the integer the second argument points to.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_multi_info_read
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_cleanup (3)
9 - curl_multi_init (3)
10 - curl_multi_perform (3)
11Protocol:
12 - All
13Added-in: 7.9.6
14---
16# NAME
18curl_multi_info_read - read multi stack information
20# SYNOPSIS
22~~~c
23#include <curl/curl.h>
25CURLMsg *curl_multi_info_read(CURLM *multi_handle, int *msgs_in_queue);
26~~~
28# DESCRIPTION
30Ask the multi handle if there are any messages from the individual transfers.
31Messages may include information such as an error code from the transfer or
32the fact that a transfer is completed. More details on these should be written
33down as well.
35Repeated calls to this function returns a new struct each time, until a NULL
36is returned as a signal that there is no more to get at this point. The
37integer pointed to with *msgs_in_queue* contains the number of remaining
38messages after this function was called.
40When you fetch a message using this function, it is removed from the internal
41queue so calling this function again does not return the same message
42again. It instead returns new messages at each new invoke until the queue is
43emptied.
45**WARNING:** The data the returned pointer points to does not survive
46calling curl_multi_cleanup(3), curl_multi_remove_handle(3) or
47curl_easy_cleanup(3).
49The *CURLMsg* struct is simple and only contains basic information. If
50more involved information is wanted, the particular "easy handle" is present
51in that struct and can be used in subsequent regular
52curl_easy_getinfo(3) calls (or similar):
54~~~c
55struct CURLMsg {
56 CURLMSG msg; /* what this message means */
57 CURL *easy_handle; /* the handle it concerns */
58 union {
59 void *whatever; /* message-specific data */
60 CURLcode result; /* return code for transfer */
61 } data;
62};
63~~~
64When **msg** is *CURLMSG_DONE*, the message identifies a transfer that
65is done, and then **result** contains the return code for the easy handle
66that completed.
68At this point, there are no other **msg** types defined.
70# %PROTOCOLS%
72# EXAMPLE
74~~~c
75int main(void)
77 CURLM *multi = curl_multi_init();
78 CURL *curl = curl_easy_init();
79 if(curl) {
80 struct CURLMsg *m;
82 /* call curl_multi_perform or curl_multi_socket_action first, then loop
83 through and check if there are any transfers that have completed */
85 do {
86 int msgq = 0;
87 m = curl_multi_info_read(multi, &msgq);
88 if(m && (m->msg == CURLMSG_DONE)) {
89 CURL *e = m->easy_handle;
90 /* m->data.result holds the error code for the transfer */
91 curl_multi_remove_handle(multi, e);
92 curl_easy_cleanup(e);
93 }
94 } while(m);
95 }
97~~~
99# %AVAILABILITY%
101# RETURN VALUE
103A pointer to a filled-in struct, or NULL if it failed or ran out of structs.
104It also writes the number of messages left in the queue (after this read) in
105the integer the second argument points to.
Diagnostics4 git calls · 164 ms
CallStatusSizeTime0164 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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 · 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.5 KiB158 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=158
git.response.bytes=1488
git.response.cache=MISS
git.response.duration_ms=158
git.fetch.wants=35f96c2db7aa4327e78425b6f01122af0a12ea77
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=1488
git.pkt.payload.max=1467
git.sideband.band1.bytes=1466
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
a5e331a4cd3e18aa
Request
9cba0ab4…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format