Artifactspublic-v0

curl

master
ply4 git calls181 ms289 KiB2 cachedprotocol v2
225 lines7.0 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#include "urldata.h"
27#include "cfilters.h"
28#include "curl_trc.h"
29#include "select.h"
31/* Test the gating in Curl_conn_adjust_pollset(): each filter chain
32 * of a connection must only get to adjust the pollset when the transfer
33 * wants to send or receive, or when that chain itself is connecting or
34 * shutting down. One chain being in connect or shutdown must not add
35 * poll events for the other, see #21671. */
37struct t2606_ctx {
38 int calls;
39 bool add_socket;
40 curl_socket_t sock;
41};
43static void t2606_cf_destroy(struct Curl_cfilter *cf,
44 struct Curl_easy *data)
46 (void)data;
47 /* ctx is owned by the test case, nothing to free */
48 cf->ctx = NULL;
51static CURLcode t2606_cf_connect(struct Curl_cfilter *cf,
52 struct Curl_easy *data,
53 bool *done)
55 (void)cf;
56 (void)data;
57 *done = TRUE;
58 return CURLE_OK;
61static CURLcode t2606_cf_adjust_pollset(struct Curl_cfilter *cf,
62 struct Curl_easy *data,
63 struct easy_pollset *ps)
65 struct t2606_ctx *ctx = cf->ctx;
66 ctx->calls++;
67 if(ctx->add_socket)
68 return Curl_pollset_add_in(data, ps, ctx->sock);
69 return CURLE_OK;
72static const struct Curl_cftype t2606_cft = {
73 "TEST-PS",
74 CF_TYPE_IP_CONNECT,
75 CURL_LOG_LVL_NONE,
76 t2606_cf_destroy,
77 t2606_cf_connect,
78 Curl_cf_def_shutdown,
79 t2606_cf_adjust_pollset,
80 Curl_cf_def_data_pending,
81 Curl_cf_def_send,
82 Curl_cf_def_recv,
83 Curl_cf_def_cntrl,
84 Curl_cf_def_conn_is_alive,
85 Curl_cf_def_conn_keep_alive,
86 Curl_cf_def_query,
87};
89struct t2606_case {
90 int id;
91 bool has_c1; /* a SECONDARYSOCKET chain exists */
92 bool c0_connected;
93 bool c1_connected;
94 bool c0_shutdown; /* shutdown started on the chain */
95 bool c1_shutdown;
96 bool xfer_io; /* the pollset holds a transfer socket already */
97 bool c0_adds; /* chain 0 adds a socket when called */
98 int exp_c0_calls;
99 int exp_c1_calls;
100};
102static CURLcode t2606_setup(CURL **easy)
104 CURLcode result = CURLE_OK;
106 global_init(CURL_GLOBAL_ALL);
107 *easy = curl_easy_init();
108 if(!*easy) {
109 curl_global_cleanup();
110 return CURLE_OUT_OF_MEMORY;
111 }
112 return result;
115static void t2606_stop(CURL *easy)
117 curl_easy_cleanup(easy);
118 curl_global_cleanup();
121static void t2606_run(struct Curl_easy *data, const struct t2606_case *tc)
123 struct connectdata *conn;
124 struct Curl_cfilter *cf0 = NULL, *cf1 = NULL;
125 struct t2606_ctx ctx0, ctx1;
126 struct easy_pollset ps;
127 CURLcode result;
128 char msg[128];
130 conn = curlx_calloc(1, sizeof(*conn));
131 abort_if(!conn, "could not allocate a connection");
133 conn->created = curlx_now();
134 conn->shutdown.start_ms[FIRSTSOCKET] =
135 conn->shutdown.start_ms[SECONDARYSOCKET] = -1;
137 memset(&ctx0, 0, sizeof(ctx0));
138 memset(&ctx1, 0, sizeof(ctx1));
139 ctx0.sock = 42;
140 ctx0.add_socket = tc->c0_adds;
141 ctx1.sock = 43;
143 result = Curl_cf_create(&cf0, &t2606_cft, &ctx0);
144 fail_unless(!result, "creating filter chain 0 failed");
145 if(!result) {
146 Curl_conn_cf_add(data, conn, FIRSTSOCKET, cf0);
147 cf0->connected = tc->c0_connected;
148 if(tc->c0_shutdown)
149 conn->shutdown.start_ms[FIRSTSOCKET] = 100;
150 }
152 if(tc->has_c1) {
153 result = Curl_cf_create(&cf1, &t2606_cft, &ctx1);
154 fail_unless(!result, "creating filter chain 1 failed");
155 if(!result) {
156 Curl_conn_cf_add(data, conn, SECONDARYSOCKET, cf1);
157 cf1->connected = tc->c1_connected;
158 if(tc->c1_shutdown)
159 conn->shutdown.start_ms[SECONDARYSOCKET] = 100;
160 }
161 }
163 Curl_pollset_init(&ps);
164 if(tc->xfer_io) {
165 result = Curl_pollset_add_in(data, &ps, 7);
166 fail_unless(!result, "preloading the pollset failed");
167 }
169 result = Curl_conn_adjust_pollset(data, conn, &ps);
171 curl_msprintf(msg, "case %d: adjust_pollset failed", tc->id);
172 fail_unless(!result, msg);
173 curl_msprintf(msg, "case %d: chain 0 called %d times, expected %d",
174 tc->id, ctx0.calls, tc->exp_c0_calls);
175 fail_unless(ctx0.calls == tc->exp_c0_calls, msg);
176 curl_msprintf(msg, "case %d: chain 1 called %d times, expected %d",
177 tc->id, ctx1.calls, tc->exp_c1_calls);
178 fail_unless(ctx1.calls == tc->exp_c1_calls, msg);
179 if(tc->c0_adds && tc->exp_c0_calls) {
180 curl_msprintf(msg, "case %d: chain 0 did not add its socket", tc->id);
181 fail_unless(ps.n > 0, msg);
182 }
184 Curl_pollset_cleanup(&ps);
185 Curl_conn_cf_discard_all(data, conn, SECONDARYSOCKET);
186 Curl_conn_cf_discard_all(data, conn, FIRSTSOCKET);
187unit_test_abort:
188 curlx_free(conn);
191static CURLcode test_unit2606(const char *arg)
193 CURL *easy;
195 UNITTEST_BEGIN(t2606_setup(&easy))
197 static const struct t2606_case TEST_CASES[] = {
198 /* both chains connected and quiet, transfer idle: nothing runs */
199 { 1, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, 0, 0 },
200 /* transfer wants IO: both chains run */
201 { 2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, 1, 1 },
202 /* chain 0 connecting, chain 1 connected and quiet: only chain 0 */
203 { 3, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, 1, 0 },
204 /* chain 1 connecting, chain 0 connected and quiet: only chain 1 */
205 { 4, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 1 },
206 /* chain 0 shutting down, chain 1 connected and quiet: only chain 0 */
207 { 5, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, 1, 0 },
208 /* chain 1 shutting down, chain 0 connected and quiet: only chain 1 */
209 { 6, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, 0, 1 },
210 /* single connected quiet chain, transfer idle: nothing runs */
211 { 7, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0 },
212 /* single chain shutting down: runs */
213 { 8, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, 1, 0 },
214 /* a socket added by connecting chain 0 must not run quiet chain 1 */
215 { 9, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, 1, 0 },
216 };
218 size_t i;
220 for(i = 0; i < CURL_ARRAYSIZE(TEST_CASES); ++i) {
221 t2606_run(easy, &TEST_CASES[i]);
222 }
224 UNITTEST_END(t2606_stop(easy))
Diagnostics4 git calls · 181 ms
CallStatusSizeTime0181 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=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
fetch2002.5 KiB176 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=176
git.response.bytes=2513
git.response.cache=MISS
git.response.duration_ms=176
git.fetch.wants=2c9d83ae4490f5f6bcfef4340d7562f057d6e0f2
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=2513
git.pkt.payload.max=2492
git.sideband.band1.bytes=2491
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
a5e2e6e128b8ecfa
Request
60f06561…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format