summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-05-11 16:36:31 -0400
committerJune McEnroe <june@causal.agency>2020-05-11 16:36:31 -0400
commite6ca38288f38707fda5f29f5308d089a54551110 (patch)
tree7c09a5dba301879ce21f44aca0158a77ddd3ea97
parentUse . as ${LDLIBS.$@} separator (diff)
downloadpounce-e6ca38288f38707fda5f29f5308d089a54551110.tar.gz
pounce-e6ca38288f38707fda5f29f5308d089a54551110.zip
Check signals after handling ready sockets
In the case where a signal arrives while handling a ready socket, it
should be handled as soon as possible, rather than waiting for poll to
return again. Signals will still be handled immediately if poll returns
-1 due to EINTR.
-rw-r--r--bounce.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/bounce.c b/bounce.c
index 1aae7a3..21355ea 100644
--- a/bounce.c
+++ b/bounce.c
@@ -458,26 +458,19 @@ int main(int argc, char *argv[]) {
 	eventAdd(server, NULL);
 
 	for (;;) {
-		int nfds = poll(event.fds, event.len, -1);
-		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
-		if (signals[SIGINT] || signals[SIGTERM]) break;
-
-		if (signals[SIGINFO]) {
-			ringInfo();
-			signals[SIGINFO] = 0;
+		for (size_t i = binds + 1; i < event.len; ++i) {
+			assert(event.clients[i]);
+			if (clientDiff(event.clients[i])) {
+				event.fds[i].events |= POLLOUT;
+			} else {
+				event.fds[i].events &= ~POLLOUT;
+			}
 		}
 
-		if (signals[SIGUSR1]) {
-			cert = splitOpen(certSplit);
-			priv = splitOpen(privSplit);
-			localConfig(cert, priv, localCA, !clientPass);
-			fclose(cert);
-			fclose(priv);
-			signals[SIGUSR1] = 0;
-		}
+		int nfds = poll(event.fds, event.len, -1);
+		if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll");
 
-		if (nfds < 0) continue;
-		for (size_t i = event.len - 1; i < event.len; --i) {
+		for (size_t i = event.len - 1; nfds > 0 && i < event.len; --i) {
 			short revents = event.fds[i].revents;
 			if (!revents) continue;
 
@@ -514,13 +507,20 @@ int main(int argc, char *argv[]) {
 			}
 		}
 
-		for (size_t i = binds + 1; i < event.len; ++i) {
-			assert(event.clients[i]);
-			if (clientDiff(event.clients[i])) {
-				event.fds[i].events |= POLLOUT;
-			} else {
-				event.fds[i].events &= ~POLLOUT;
-			}
+		if (signals[SIGINT] || signals[SIGTERM]) break;
+
+		if (signals[SIGINFO]) {
+			ringInfo();
+			signals[SIGINFO] = 0;
+		}
+
+		if (signals[SIGUSR1]) {
+			cert = splitOpen(certSplit);
+			priv = splitOpen(privSplit);
+			localConfig(cert, priv, localCA, !clientPass);
+			fclose(cert);
+			fclose(priv);
+			signals[SIGUSR1] = 0;
 		}
 	}
 
olspan='3' class='logmsg'> 2020-04-26Rearrange some of archive.hJune McEnroe 2020-04-26Free part.parts.ptrJune McEnroe Oops. 2020-04-26Rename part->id to part->contentIDJune McEnroe Disambiguate with messageID. 2020-04-26Iterate through nested multiparts to find content for AtomJune McEnroe Also fixes content for multipart/signed. 2020-04-26Include Cc address in reply mailtosJune McEnroe 2020-04-26Use %R for RFC numbers in STANDARDS sectionJune McEnroe 2020-04-26Add mailto spec to STANDARDSJune McEnroe 2020-04-26Increase space between nav itemsJune McEnroe 2020-04-26Add mailto address for the archiveJune McEnroe 2020-04-26Put dates on new lines in indexJune McEnroe 2020-04-26Include <> around Message-Id in mailto: URLsJune McEnroe 2020-04-26Add link to index on thread pagesJune McEnroe 2020-04-26Fall back to Content-Type name parameter for attachmentsJune McEnroe 2020-04-26Remove margins in article.message headerJune McEnroe 2020-04-26Generate index.atomJune McEnroe 2020-04-26Generate XHTML content in Atom entriesJune McEnroe 2020-04-25Style index pageJune McEnroe 2020-04-25Render index.htmlJune McEnroe 2020-04-25Wrap <summary> replies count in <data>June McEnroe 2020-04-25Accumulate thread envelopes before concatenationJune McEnroe 2020-04-24Free envelope in concatDataJune McEnroe 2020-04-24Use replyTo address in mailto:June McEnroe 2020-04-23Wrap quoted lines in <q>June McEnroe