summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bounce.c9
-rw-r--r--bounce.h1
-rw-r--r--ring.c11
3 files changed, 21 insertions, 0 deletions
diff --git a/bounce.c b/bounce.c
index 1015625..dcf9eab 100644
--- a/bounce.c
+++ b/bounce.c
@@ -30,6 +30,10 @@
 
 #include "bounce.h"
 
+#ifndef SIGINFO
+#define SIGINFO SIGUSR2
+#endif
+
 static volatile sig_atomic_t signals[NSIG];
 static void signalHandler(int signal) {
 	signals[signal] = 1;
@@ -159,6 +163,7 @@ int main(int argc, char *argv[]) {
 
 	signal(SIGINT, signalHandler);
 	signal(SIGTERM, signalHandler);
+	signal(SIGINFO, signalHandler);
 	signal(SIGUSR1, signalHandler);
 
 	size_t clients = 0;
@@ -167,6 +172,10 @@ int main(int argc, char *argv[]) {
 		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
 
 		if (signals[SIGINT] || signals[SIGTERM]) break;
+		if (signals[SIGINFO]) {
+			ringInfo();
+			signals[SIGINFO] = 0;
+		}
 		if (signals[SIGUSR1]) {
 			listenConfig(certPath, privPath);
 			signals[SIGUSR1] = 0;
diff --git a/bounce.h b/bounce.h
index b0d6d18..4a04acf 100644
--- a/bounce.h
+++ b/bounce.h
@@ -60,6 +60,7 @@ void ringProduce(const char *line);
 size_t ringConsumer(const char *name);
 size_t ringDiff(size_t consumer);
 const char *ringConsume(time_t *time, size_t consumer);
+void ringInfo(void);
 
 void listenConfig(const char *cert, const char *priv);
 size_t listenBind(int fds[], size_t cap, const char *host, const char *port);
diff --git a/ring.c b/ring.c
index d66961d..912d0d3 100644
--- a/ring.c
+++ b/ring.c
@@ -16,6 +16,7 @@
 
 #include <assert.h>
 #include <err.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
 #include <time.h>
@@ -79,3 +80,13 @@ const char *ringConsume(time_t *time, size_t consumer) {
 	if (time) *time = ring.times[i];
 	return ring.lines[i];
 }
+
+void ringInfo(void) {
+	fprintf(stderr, "producer: %zu\n", ring.write);
+	for (size_t i = 0; i < read.len; ++i) {
+		fprintf(
+			stderr, "consumer %s: %zu (%zu)\n",
+			read.names[i], read.ptrs[i], ring.write - read.ptrs[i]
+		);
+	}
+}