Artifactspublic-v0

curl

master
ply4 git calls34 ms289 KiB3 cachedprotocol v2
232 lines7.7 KiBRaw
1#ifndef HEADER_CURL_SELECT_H
2#define HEADER_CURL_SELECT_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#ifdef HAVE_POLL_H
29#include <poll.h>
30#elif defined(HAVE_SYS_POLL_H)
31#include <sys/poll.h>
32#endif
34/*
35 * Definition of pollfd struct and constants for platforms lacking them.
36 */
38#if !defined(HAVE_SYS_POLL_H) && !defined(HAVE_POLL_H) && !defined(POLLIN)
40#define POLLIN 0x01
41#define POLLPRI 0x02
42#define POLLOUT 0x04
43#define POLLERR 0x08
44#define POLLHUP 0x10
45#define POLLNVAL 0x20
47struct pollfd {
48 curl_socket_t fd;
49 short events;
50 short revents;
51};
53#endif
55#ifndef POLLRDNORM
56#define POLLRDNORM POLLIN
57#endif
59#ifndef POLLWRNORM
60#define POLLWRNORM POLLOUT
61#endif
63#ifndef POLLRDBAND
64#define POLLRDBAND POLLPRI
65#endif
67/* there are three CSELECT defines that are defined in the public header that
68 are exposed to users, but this *IN2 bit is only ever used internally and
69 therefore defined here */
70#define CURL_CSELECT_IN2 (CURL_CSELECT_ERR << 1)
72int Curl_socket_check(curl_socket_t readfd0,
73 curl_socket_t readfd1,
74 curl_socket_t writefd,
75 timediff_t timeout_ms);
76#define SOCKET_READABLE(x, z) \
77 Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
78#define SOCKET_WRITABLE(x, z) \
79 Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
81int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
83/* With Winsock the valid range is [0..INVALID_SOCKET-1] according to
84 https://learn.microsoft.com/windows/win32/winsock/socket-data-type-2 */
85#ifdef USE_WINSOCK
86#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
87#define FDSET_SOCK(x) 1
88#define VERIFY_SOCK(x) \
89 do { \
90 if(!VALID_SOCK(x)) { \
91 SET_SOCKERRNO(SOCKEINVAL); \
92 return -1; \
93 } \
94 } while(0)
95#else
96#define VALID_SOCK(s) ((s) >= 0)
98/* If the socket is small enough to get set or read from an fdset */
99#define FDSET_SOCK(s) ((s) < FD_SETSIZE)
101#define VERIFY_SOCK(x) \
102 do { \
103 if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \
104 SET_SOCKERRNO(SOCKEINVAL); \
105 return -1; \
106 } \
107 } while(0)
108#endif
110/* Keep the sockets to poll for an easy handle.
111 * `actions` are bitmaps of CURL_POLL_IN and CURL_POLL_OUT.
112 * Starts with small capacity, grows on demand.
113 */
114#define EZ_POLLSET_DEF_COUNT 2
116struct easy_pollset {
117 curl_socket_t *sockets;
118 unsigned char *actions;
119 unsigned int n;
120 unsigned int count;
121#ifdef DEBUGBUILD
122 int init;
123#endif
124 curl_socket_t def_sockets[EZ_POLLSET_DEF_COUNT];
125 unsigned char def_actions[EZ_POLLSET_DEF_COUNT];
126};
128#ifdef DEBUGBUILD
129#define CURL_EASY_POLLSET_MAGIC 0x7a657370
130#endif
132/* allocate and initialize */
133struct easy_pollset *Curl_pollset_create(void);
135/* Initialize before first use */
136void Curl_pollset_init(struct easy_pollset *ps);
137/* Free any allocated resources */
138void Curl_pollset_cleanup(struct easy_pollset *ps);
139/* Reset to an empty pollset */
140void Curl_pollset_reset(struct easy_pollset *ps);
141/* Move pollset from to pollset to, replacing all in to,
142 * leaving from empty. */
143void Curl_pollset_move(struct easy_pollset *to, struct easy_pollset *from);
145/* Change the poll flags (CURL_POLL_IN/CURL_POLL_OUT) to the poll set for
146 * socket `sock`. If the socket is not already part of the poll set, it
147 * will be added.
148 * If the socket is present and all poll flags are cleared, it will be removed.
149 */
150CURLcode Curl_pollset_change(struct Curl_easy *data,
151 struct easy_pollset *ps, curl_socket_t sock,
152 int add_flags,
153 int remove_flags) WARN_UNUSED_RESULT;
155CURLcode Curl_pollset_set(struct Curl_easy *data,
156 struct easy_pollset *ps, curl_socket_t sock,
157 bool do_in, bool do_out) WARN_UNUSED_RESULT;
159#define Curl_pollset_add_in(data, ps, sock) \
160 Curl_pollset_change(data, ps, sock, CURL_POLL_IN, 0)
161#define Curl_pollset_remove_in(data, ps, sock) \
162 Curl_pollset_change(data, ps, sock, 0, CURL_POLL_IN)
163#define Curl_pollset_add_out(data, ps, sock) \
164 Curl_pollset_change(data, ps, sock, CURL_POLL_OUT, 0)
165#define Curl_pollset_remove_out(data, ps, sock) \
166 Curl_pollset_change(data, ps, sock, 0, CURL_POLL_OUT)
167#define Curl_pollset_add_inout(data, ps, sock) \
168 Curl_pollset_change(data, ps, sock, CURL_POLL_IN | CURL_POLL_OUT, 0)
169#define Curl_pollset_set_in_only(data, ps, sock) \
170 Curl_pollset_change(data, ps, sock, CURL_POLL_IN, CURL_POLL_OUT)
171#define Curl_pollset_set_out_only(data, ps, sock) \
172 Curl_pollset_change(data, ps, sock, CURL_POLL_OUT, CURL_POLL_IN)
174void Curl_pollset_remove(struct easy_pollset *ps, curl_socket_t sock);
176/* return < = on error, 0 on timeout or how many sockets are ready */
177int Curl_pollset_poll(struct Curl_easy *data,
178 struct easy_pollset *ps,
179 timediff_t timeout_ms);
181/**
182 * Check if the pollset, as is, wants to read and/or write regarding
183 * the given socket.
184 */
185void Curl_pollset_check(struct Curl_easy *data,
186 struct easy_pollset *ps, curl_socket_t sock,
187 bool *pwant_read, bool *pwant_write);
189/* TRUE if the pollset contains socket with CURL_POLL_IN. */
190bool Curl_pollset_want_recv(struct Curl_easy *data,
191 struct easy_pollset *ps,
192 curl_socket_t sock);
193/* TRUE if the pollset contains socket with CURL_POLL_OUT. */
194bool Curl_pollset_want_send(struct Curl_easy *data,
195 struct easy_pollset *ps,
196 curl_socket_t sock);
198struct curl_pollfds {
199 struct pollfd *pfds;
200 unsigned int n;
201 unsigned int count;
202 BIT(allocated_pfds);
203};
205void Curl_pollfds_init(struct curl_pollfds *cpfds,
206 struct pollfd *static_pfds,
207 unsigned int static_count);
209void Curl_pollfds_reset(struct curl_pollfds *cpfds);
211void Curl_pollfds_cleanup(struct curl_pollfds *cpfds);
213CURLcode Curl_pollfds_add_ps(struct curl_pollfds *cpfds,
214 struct easy_pollset *ps);
216CURLcode Curl_pollfds_add_sock(struct curl_pollfds *cpfds,
217 curl_socket_t sock, short events);
219struct Curl_waitfds {
220 struct curl_waitfd *wfds;
221 unsigned int n;
222 unsigned int count;
223};
225void Curl_waitfds_init(struct Curl_waitfds *cwfds,
226 struct curl_waitfd *static_wfds,
227 unsigned int static_count);
229unsigned int Curl_waitfds_add_ps(struct Curl_waitfds *cwfds,
230 struct easy_pollset *ps);
232#endif /* HEADER_CURL_SELECT_H */
Diagnostics4 git calls · 34 ms
CallStatusSizeTime034 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=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 · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=27
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=4
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
fetch2002.4 KiB · hit27 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2495
git.response.cache=HIT
git.response.duration_ms=27
git.fetch.wants=f2e9cddd6553f5d5cc6eb7e2e0fa1ec91472494b
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=2495
git.pkt.payload.max=2474
git.sideband.band1.bytes=2473
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
a5e272aefbd0d806
Request
e885791c…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format