Codebergdnkl

foot

master
ply5 git calls491 ms29 KiB3 cachedprotocol v2
120 lines2.5 KiBRaw
1#include "reaper.h"
3#include <stdlib.h>
4#include <unistd.h>
5#include <sys/epoll.h>
6#include <signal.h>
7#include <sys/wait.h>
8#include <tllist.h>
10#define LOG_MODULE "reaper"
11#define LOG_ENABLE_DBG 0
12#include "log.h"
14struct child {
15 pid_t pid;
16 reaper_cb cb;
17 void *cb_data;
18};
20struct reaper {
21 struct fdm *fdm;
22 tll(struct child) children;
23};
25static bool fdm_reap(struct fdm *fdm, int signo, void *data);
27struct reaper *
28reaper_init(struct fdm *fdm)
30 struct reaper *reaper = malloc(sizeof(*reaper));
31 if (unlikely(reaper == NULL)) {
32 LOG_ERRNO("malloc() failed");
33 return NULL;
34 }
36 *reaper = (struct reaper){
37 .fdm = fdm,
38 .children = tll_init(),
39 };
41 if (!fdm_signal_add(fdm, SIGCHLD, &fdm_reap, reaper))
42 goto err;
44 return reaper;
46err:
47 tll_free(reaper->children);
48 free(reaper);
49 return NULL;
52void
53reaper_destroy(struct reaper *reaper)
55 if (reaper == NULL)
56 return;
58 fdm_signal_del(reaper->fdm, SIGCHLD);
59 tll_free(reaper->children);
60 free(reaper);
63void
64reaper_add(struct reaper *reaper, pid_t pid, reaper_cb cb, void *cb_data)
66 LOG_DBG("adding pid=%d", pid);
67 tll_push_back(
68 reaper->children,
69 ((struct child){.pid = pid, .cb = cb, .cb_data = cb_data}));
72void
73reaper_del(struct reaper *reaper, pid_t pid)
75 tll_foreach(reaper->children, it) {
76 if (it->item.pid == pid) {
77 tll_remove(reaper->children, it);
78 break;
79 }
80 }
83static bool
84fdm_reap(struct fdm *fdm, int signo, void *data)
86 struct reaper *reaper = data;
88 while (true) {
89 int status;
90 pid_t pid = waitpid(-1, &status, WNOHANG);
91 if (pid <= 0)
92 break;
94 if (WIFEXITED(status))
95 LOG_DBG("pid=%d: exited with status=%d", pid, WEXITSTATUS(status));
96 else if (WIFSIGNALED(status))
97 LOG_DBG("pid=%d: killed by signal=%d", pid, WTERMSIG(status));
98 else
99 LOG_DBG("pid=%d: died of unknown resason", pid);
101 tll_foreach(reaper->children, it) {
102 struct child *_child = &it->item;
104 if (_child->pid != pid)
105 continue;
107 /* Make sure we remove it *before* the callback, since it too
108 * may remove it */
109 struct child child = it->item;
110 tll_remove(reaper->children, it);
112 if (child.cb != NULL)
113 child.cb(reaper, child.pid, status, child.cb_data);
115 break;
116 }
117 }
119 return true;
Diagnostics5 git calls · 491 ms
CallStatusSizeTime0491 ms
discover200178 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=178
git.server.agent=git/2.56.1-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=178
git.pkt.payload.max=35
ls-refs20010 KiB467 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=396
git.response.bytes=10322
git.response.cache=EXPIRED
git.response.duration_ms=467
git.protocol.version=2
git.pkt.frames=108
git.pkt.data=107
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=10322
git.pkt.payload.max=106
git.ls_refs.count=107
git.ls_refs.head=refs/heads/master
fetchtree:0 · deepen 102009.3 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=9489
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
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=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=9489
git.pkt.payload.max=9389
git.sideband.band1.bytes=9389
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=10
git.pack.bytes=9389
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=de930681b6073ba5b599a0f956bfbd114762ad5a
git.pack.full=10
Open pack map
fetchcombine:blob:none+tree:2 · deepen 12008.6 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=8830
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=8830
git.pkt.payload.max=8730
git.sideband.band1.bytes=8730
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=14
git.pack.bytes=8730
git.fetch.wide.objects=14
git.fetch.wide.extra_bytes=9909
git.fetch.wide.blobs=0
fetch200947 B · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=21
git.response.bytes=947
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=4abc785e3ab36068436f5f0e4c79f48e85cbbf5a
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=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=947
git.pkt.payload.max=920
git.sideband.band1.bytes=920
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://codeberg.org/dnkl/foot
Ref
refs/heads/master
Commit
c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
cf-ray
a5e1802c4c1e3014
Request
3b948364…
Protocol
v2 · sha1
Agent
git/2.56.1-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format