Artifactspublic-v0

curl

master
ply4 git calls137 ms288 KiB2 cachedprotocol v2
84 lines2.3 KiBRaw

NAME

curl_multi_assign - set data to associate with an internal socket

SYNOPSIS

c
#include <curl/curl.h>

CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
                            void *sockptr);

DESCRIPTION

This function creates an association in the multi handle between the given socket and a private pointer of the application. This is designed for curl_multi_socket_action(3) uses.

When set, the sockptr pointer is passed to all future socket callbacks for the specific sockfd socket, until the socket stops being monitored (CURL_POLL_REMOVE is sent to the CURLMOPT_SOCKETFUNCTION(3) callback).

If the given sockfd is not already in use by libcurl, this function returns an error.

libcurl only keeps one single pointer associated with a socket, so calling this function several times for the same socket makes the last set pointer get used.

It is acceptable to call this function from your multi callback functions.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURLM *multi = curl_multi_init();
  int private_data = 123;
  curl_socket_t fd = 0; /* file descriptor to associate our data with */

  /* make our struct pointer associated with socket fd */
  CURLMcode mresult = curl_multi_assign(multi, fd, &private_data);
  if(mresult)
    printf("error: %s\n", curl_multi_strerror(mresult));
}

TYPICAL USAGE

In a typical application you allocate a struct or at least use some kind of semi-dynamic data for each socket that we must wait for action on when using the curl_multi_socket_action(3) approach.

When our socket-callback gets called by libcurl and we get to know about yet another socket to wait for, we can use curl_multi_assign(3) to point out the particular data so that when we get updates about this same socket again, we do not have to find the struct associated with this socket by ourselves.

%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_assign
5Section: 3
6Source: libcurl
7See-also:
8 - curl_multi_setopt (3)
9 - curl_multi_socket_action (3)
10 - CURLMOPT_SOCKETFUNCTION (3)
11Protocol:
12 - All
13Added-in: 7.15.5
14---
16# NAME
18curl_multi_assign - set data to associate with an internal socket
20# SYNOPSIS
22~~~c
23#include <curl/curl.h>
25CURLMcode curl_multi_assign(CURLM *multi_handle, curl_socket_t sockfd,
26 void *sockptr);
27~~~
29# DESCRIPTION
31This function creates an association in the multi handle between the given
32socket and a private pointer of the application. This is designed for
33curl_multi_socket_action(3) uses.
35When set, the *sockptr* pointer is passed to all future socket callbacks for
36the specific *sockfd* socket, until the socket stops being monitored
37(CURL_POLL_REMOVE is sent to the CURLMOPT_SOCKETFUNCTION(3) callback).
39If the given *sockfd* is not already in use by libcurl, this function returns
40an error.
42libcurl only keeps one single pointer associated with a socket, so calling
43this function several times for the same socket makes the last set pointer get
44used.
46It is acceptable to call this function from your multi callback functions.
48# %PROTOCOLS%
50# EXAMPLE
52~~~c
53int main(void)
55 CURLM *multi = curl_multi_init();
56 int private_data = 123;
57 curl_socket_t fd = 0; /* file descriptor to associate our data with */
59 /* make our struct pointer associated with socket fd */
60 CURLMcode mresult = curl_multi_assign(multi, fd, &private_data);
61 if(mresult)
62 printf("error: %s\n", curl_multi_strerror(mresult));
64~~~
66# TYPICAL USAGE
68In a typical application you allocate a struct or at least use some kind of
69semi-dynamic data for each socket that we must wait for action on when using
70the curl_multi_socket_action(3) approach.
72When our socket-callback gets called by libcurl and we get to know about yet
73another socket to wait for, we can use curl_multi_assign(3) to point out the
74particular data so that when we get updates about this same socket again, we
75do not have to find the struct associated with this socket by ourselves.
77# %AVAILABILITY%
79# RETURN VALUE
81This function returns a CURLMcode indicating success or error.
83CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
84libcurl-errors(3).
Diagnostics4 git calls · 137 ms
CallStatusSizeTime0137 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 · 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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
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.2 KiB132 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=132
git.response.bytes=1252
git.response.cache=MISS
git.response.duration_ms=132
git.fetch.wants=7d1eaac4ed3d6dbd6c95d2fee7ef2365dedb907f
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=1252
git.pkt.payload.max=1231
git.sideband.band1.bytes=1230
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
a5e31cf33e2f8682
Request
6073f81a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format