[master] 24c7d1542 vev: keep a copy of siginfo_t in vevsig
Nils Goroll
nils.goroll at uplex.de
Mon Sep 30 14:28:06 UTC 2024
commit 24c7d154207dcea0e4ace3e933a8464aa6b634df
Author: Thibaut Artis <thibaut.artis at varnish-software.com>
Date: Fri Apr 12 17:37:51 2024 +0200
vev: keep a copy of siginfo_t in vevsig
(OBE commit message removed during merge/rebase by @nigoroll)
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index d0b28bf61..f49bb358d 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -38,6 +38,7 @@
#include <fcntl.h>
#include <poll.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 9c4e01e9c..cf437cc60 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -33,7 +33,10 @@
#include "config.h"
+#include <errno.h>
+#include <fcntl.h>
#include <fnmatch.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/include/vev.h b/include/vev.h
index 197c14882..556abc648 100644
--- a/include/vev.h
+++ b/include/vev.h
@@ -53,6 +53,7 @@ struct vev {
unsigned sig_flags;
double timeout;
vev_cb_f *callback;
+ siginfo_t *siginfo;
void *priv;
/* priv */
diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c
index c9335e6a1..ff097310d 100644
--- a/lib/libvarnish/vev.c
+++ b/lib/libvarnish/vev.c
@@ -59,6 +59,7 @@ struct vevsig {
struct vev *vev;
struct sigaction sigact;
unsigned char happened;
+ siginfo_t siginfo[1];
};
static struct vevsig *vev_sigs;
@@ -183,8 +184,11 @@ vev_sigaction(int sig, siginfo_t *siginfo, void *ctx)
assert(sig < vev_nsig);
assert(vev_sigs != NULL);
es = &vev_sigs[sig];
- if (!es->happened)
+ if (!es->happened) {
es->vevb->psig++;
+ memcpy(es->siginfo, siginfo, sizeof *es->siginfo);
+ es->vev->siginfo = es->siginfo;
+ }
es->happened = 1;
}
@@ -400,6 +404,10 @@ vev_sched_signal(struct vev_root *evb)
e = es->vev;
assert(e != NULL);
i = e->callback(e, VEV__SIG);
+ if (e->siginfo != NULL) {
+ e->siginfo = NULL;
+ memset(es->siginfo, 0, sizeof *es->siginfo);
+ }
if (i) {
VEV_Stop(evb, e);
free(e);
More information about the varnish-commit
mailing list