Artifactspublic-v0

curl

master
ply4 git calls347 ms289 KiB2 cachedprotocol v2
171 lines6.5 KiBRaw
1#ifndef HEADER_CURL_CONNCACHE_H
2#define HEADER_CURL_CONNCACHE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 * Copyright (C) Linus Nielsen Feltzing, <linus@haxx.se>
12 *
13 * This software is licensed as described in the file COPYING, which
14 * you should have received as part of this distribution. The terms
15 * are also available at https://curl.se/docs/copyright.html.
16 *
17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18 * copies of the Software, and permit persons to whom the Software is
19 * furnished to do so, under the terms of the COPYING file.
20 *
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
23 *
24 * SPDX-License-Identifier: curl
25 *
26 ***************************************************************************/
27#include "uint-bset.h"
28#include "uint-table.h"
29#include "curlx/timeval.h"
31struct connectdata;
32struct Curl_easy;
33struct curl_pollfds;
34struct Curl_waitfds;
35struct Curl_multi;
36struct Curl_share;
38/**
39 * Close and destroy the connection.
40 * If the connection is in a cpool, remove it.
41 * If a `cshutdn` is available (e.g. data has a multi handle),
42 * pass the connection to that for controlled shutdown.
43 * Otherwise terminate it right away.
44 * Takes ownership of `conn`.
45 * `data` should not be attached to a connection.
46 */
47void Curl_conn_close(struct Curl_easy *data,
48 struct connectdata *conn,
49 bool aborted);
51struct cpool {
52 struct uint32_tbl conns; /* connections added to this pool */
53 struct uint32_bset idles; /* pool_ids of conns being idle */
54 struct Curl_hash dest2bundle; /* conn destination sets */
55 curl_off_t next_connection_id;
56 curl_off_t next_easy_id;
57 struct curltime last_cleanup;
58 struct Curl_share *share; /* != NULL if pool belongs to share */
59 BIT(locked);
60 BIT(initialized);
61 BIT(in_shutdown);
62};
64/* Init the pool, pass multi only if pool is owned by it.
65 * Cannot fail.
66 */
67void Curl_cpool_init(struct cpool *cpool,
68 struct Curl_share *share,
69 size_t size);
71/* Destroy all connections and free all members */
72void Curl_cpool_destroy(struct cpool *cpool,
73 struct Curl_easy *admin);
75/* Init the transfer to be used within its connection pool.
76 * Assigns `data->id`. */
77void Curl_cpool_xfer_init(struct Curl_easy *data);
79/* Get the connection last used by data,
80 * if there was one and it still exists. */
81struct connectdata *Curl_cpool_get_last_conn(struct Curl_easy *data);
83/* Add the connection to the pool. */
84CURLcode Curl_cpool_add(struct Curl_easy *data,
85 struct connectdata *conn,
86 uint32_t max_total,
87 uint32_t max_host,
88 const struct curltime *pnow) WARN_UNUSED_RESULT;
90/* Connection was used at the given time. */
91void Curl_cpool_conn_was_used(struct Curl_easy *data,
92 struct connectdata *conn,
93 const struct curltime *pnow);
95/* Return connection age in milliseconds since its creation. */
96timediff_t Curl_cpool_conn_age_ms(struct Curl_easy *data,
97 struct connectdata *conn,
98 const struct curltime *pnow);
100typedef enum {
101 CPOOL_MATCH_FOUND, /* The passed `conn` matches, stop looking further */
102 CPOOL_MATCH_CONT, /* No match, continue looking */
103 CPOOL_MATCH_CLOSE, /* No match, close `conn`, continue looking */
104 CPOOL_MATCH_TOO_OLD /* No match, `conn` is too old, close when idle */
105} cpool_match_result;
107/* Return of conn is suitable. If so, stops iteration. */
108typedef cpool_match_result
109 Curl_cpool_conn_match_cb(struct connectdata *conn, void *userdata);
111/* Act on the result of the find, may override it. */
112typedef bool Curl_cpool_done_match_cb(void *userdata);
114/**
115 * Find a connection in the pool matching `destination`.
116 * All callbacks are invoked while the pool's lock is held.
117 * @param data current transfer
118 * @param destination match against `conn->destination` in pool
119 * @param prune_dead perform reaping of dead connections at start
120 * @param pnow timestamp of operation
121 * @param conn_cb must be present, called for each connection in the
122 * bundle until it returns TRUE
123 * @return combined result of last conn_db and result_cb or FALSE if no
124 connections were present.
125 */
126bool Curl_cpool_find(struct Curl_easy *data,
127 const char *destination,
128 bool prune_dead,
129 const struct curltime *pnow,
130 Curl_cpool_conn_match_cb *conn_cb,
131 Curl_cpool_done_match_cb *done_cb,
132 void *userdata);
134/**
135 * Perform upkeep actions on connections in the transfer's pool.
136 */
137CURLcode Curl_cpool_upkeep(struct Curl_easy *data);
139typedef enum {
140 CPOOL_DO_KEEP, /* Keep the connection, still in use */
141 CPOOL_DO_IDLE, /* Connection is idle, may get closed now */
142 CPOOL_DO_CLOSE, /* Close the connection (clean) */
143 CPOOL_DO_TERMINATE /* Terminate the connection (unclean) */
144} cpool_do_result;
146typedef cpool_do_result Curl_cpool_return_cb(struct Curl_easy *data,
147 struct connectdata *conn,
148 void *cbdata,
149 const struct curltime *pnow);
151/**
152 * Invoked the callback for the given data + connection under the
153 * connection pool's lock.
154 * The callback is always invoked, even if the transfer has no connection
155 * pool associated.
156 */
157void Curl_cpool_return(struct Curl_easy *data,
158 struct connectdata *conn,
159 Curl_cpool_return_cb *cb, void *cbdata,
160 const struct curltime *pnow);
162/* Close all unused connections, prevent reuse of existing ones. */
163void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin);
165/* Return TRUE iff the given connection is considered healthy, e.g.
166 * usable for more transfers. */
167bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
168 struct Curl_easy *data,
169 const struct curltime *pnow);
171#endif /* HEADER_CURL_CONNCACHE_H */
Diagnostics4 git calls · 347 ms
CallStatusSizeTime0347 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=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=341
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.3 KiB341 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2403
git.response.cache=MISS
git.response.duration_ms=341
git.fetch.wants=7b685f9f209af1ffea8cba472be61ea14ff5b3e4
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=2403
git.pkt.payload.max=2382
git.sideband.band1.bytes=2381
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
a5e2db860e52c125
Request
3326f50a…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format