Artifactspublic-v0

curl

master
ply4 git calls156 ms288 KiB2 cachedprotocol v2
95 lines2.5 KiBRaw

NAME

curl_multi_timeout - how long to wait for action before proceeding

SYNOPSIS

c
#include <curl/curl.h>

CURLMcode curl_multi_timeout(CURLM *multi_handle, long *timeout);

DESCRIPTION

An application using the libcurl multi interface should call curl_multi_timeout(3) to figure out how long it should wait for socket actions - at most - before proceeding.

Proceeding means either doing the socket-style timeout action: call the curl_multi_socket_action(3) function with the sockfd argument set to CURL_SOCKET_TIMEOUT, or call curl_multi_perform(3) if you are using the simpler and older multi interface approach.

The timeout value returned in the long timeout_ms points to, is in number of milliseconds at this moment. If 0, it means you should proceed immediately without waiting for anything. If it returns -1, there is no timeout at all set.

An application that uses the multi_socket API should not use this function. It should instead use the CURLMOPT_TIMERFUNCTION(3) option for proper and desired behavior.

Note: if libcurl returns a -1 timeout here, it means that libcurl currently has no stored timeout value. You must not wait too long (more than a few seconds perhaps) before you call curl_multi_perform(3) again.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  struct timeval timeout;
  long timeo;
  fd_set fdread;
  fd_set fdwrite;
  fd_set fdexcep;
  int maxfd = 2;
  CURLM *multi = curl_multi_init();

  curl_multi_timeout(multi, &timeo);
  if(timeo < 0)
    /* no set timeout, use a default */
    timeo = 980;

  timeout.tv_sec = timeo / 1000;
  timeout.tv_usec = (timeo % 1000) * 1000;

  /* wait for activities no longer than the set timeout */
  select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
}

TYPICAL USAGE

Call curl_multi_timeout(3), then wait for action on the sockets. Figure out which sockets to wait for by calling curl_multi_fdset(3).

When there is activity or timeout, call curl_multi_perform(3) and then loop - until all transfers are complete.

%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_timeout
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_fdset (3)
9 - curl_multi_info_read (3)
10 - curl_multi_setopt (3)
11 - curl_multi_socket (3)
12Protocol:
13 - All
14Added-in: 7.15.4
15---
17# NAME
19curl_multi_timeout - how long to wait for action before proceeding
21# SYNOPSIS
23~~~c
24#include <curl/curl.h>
26CURLMcode curl_multi_timeout(CURLM *multi_handle, long *timeout);
27~~~
29# DESCRIPTION
31An application using the libcurl multi interface should call
32curl_multi_timeout(3) to figure out how long it should wait for socket
33actions - at most - before proceeding.
35Proceeding means either doing the socket-style timeout action: call the
36curl_multi_socket_action(3) function with the **sockfd** argument set
37to CURL_SOCKET_TIMEOUT, or call curl_multi_perform(3) if you are using
38the simpler and older multi interface approach.
40The timeout value returned in the long **timeout_ms** points to, is in number
41of milliseconds at this moment. If 0, it means you should proceed immediately
42without waiting for anything. If it returns -1, there is no timeout at all set.
44An application that uses the *multi_socket* API should not use this function.
45It should instead use the CURLMOPT_TIMERFUNCTION(3) option for proper and
46desired behavior.
48Note: if libcurl returns a -1 timeout here, it means that libcurl currently
49has no stored timeout value. You must not wait too long (more than a few
50seconds perhaps) before you call curl_multi_perform(3) again.
52# %PROTOCOLS%
54# EXAMPLE
56~~~c
57int main(void)
59 struct timeval timeout;
60 long timeo;
61 fd_set fdread;
62 fd_set fdwrite;
63 fd_set fdexcep;
64 int maxfd = 2;
65 CURLM *multi = curl_multi_init();
67 curl_multi_timeout(multi, &timeo);
68 if(timeo < 0)
69 /* no set timeout, use a default */
70 timeo = 980;
72 timeout.tv_sec = timeo / 1000;
73 timeout.tv_usec = (timeo % 1000) * 1000;
75 /* wait for activities no longer than the set timeout */
76 select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
78~~~
80# TYPICAL USAGE
82Call curl_multi_timeout(3), then wait for action on the sockets. Figure
83out which sockets to wait for by calling curl_multi_fdset(3).
85When there is activity or timeout, call curl_multi_perform(3) and then
86loop - until all transfers are complete.
88# %AVAILABILITY%
90# RETURN VALUE
92This function returns a CURLMcode indicating success or error.
94CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
95libcurl-errors(3).
Diagnostics4 git calls · 156 ms
CallStatusSizeTime0156 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
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 · 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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=150
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
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 KiB150 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1312
git.response.cache=MISS
git.response.duration_ms=150
git.fetch.wants=a4a7fa66fa126cbdfaaaffc279901f274eadd24a
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=1312
git.pkt.payload.max=1291
git.sideband.band1.bytes=1290
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
a5e1a48278735e44
Request
a9432b92…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format