From c3d62b87996337130f7cdfe6787c92d882196be2 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 6 May 2017 21:35:44 +0200
Subject: Avoid the "poller_fd::closed" feature
Reliability enhancement for Linux.
This feature was created for ponymap, however we don't care about an
extra syscall in most places. Doing it right even saves lines.
---
degesch.c | 7 ++-----
kike.c | 7 +++----
zyklonb.c | 6 ++----
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/degesch.c b/degesch.c
index 4a57248..81e893c 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1862,9 +1862,8 @@ server_destroy (struct server *self)
if (self->socket != -1)
{
- xclose (self->socket);
- self->socket_event.closed = true;
poller_fd_reset (&self->socket_event);
+ xclose (self->socket);
}
str_free (&self->read_buffer);
str_free (&self->write_buffer);
@@ -4844,13 +4843,11 @@ irc_destroy_transport (struct server *s)
s->transport->cleanup (s);
s->transport = NULL;
+ poller_fd_reset (&s->socket_event);
xclose (s->socket);
s->socket = -1;
s->state = IRC_DISCONNECTED;
- s->socket_event.closed = true;
- poller_fd_reset (&s->socket_event);
-
str_reset (&s->read_buffer);
str_reset (&s->write_buffer);
}
diff --git a/kike.c b/kike.c
index 4772c29..6073ea0 100644
--- a/kike.c
+++ b/kike.c
@@ -693,9 +693,8 @@ server_context_free (struct server_context *self)
for (size_t i = 0; i < self->n_listen_fds; i++)
{
- xclose (self->listen_fds[i]);
- self->listen_events[i].closed = true;
poller_fd_reset (&self->listen_events[i]);
+ xclose (self->listen_fds[i]);
}
free (self->listen_fds);
free (self->listen_events);
@@ -745,9 +744,8 @@ irc_initiate_quit (struct server_context *ctx)
for (size_t i = 0; i < ctx->n_listen_fds; i++)
{
- xclose (ctx->listen_fds[i]);
- ctx->listen_events[i].closed = true;
poller_fd_reset (&ctx->listen_events[i]);
+ xclose (ctx->listen_fds[i]);
}
ctx->n_listen_fds = 0;
@@ -933,6 +931,7 @@ client_kill (struct client *c, const char *reason)
xclose (c->socket_fd);
c->socket_fd = -1;
+ // We don't fork any children, this is okay
c->socket_event.closed = true;
poller_fd_reset (&c->socket_event);
client_cancel_timers (c);
diff --git a/zyklonb.c b/zyklonb.c
index fd0c80a..d3de92d 100644
--- a/zyklonb.c
+++ b/zyklonb.c
@@ -203,8 +203,8 @@ bot_context_free (struct bot_context *self)
if (self->irc_fd != -1)
{
- xclose (self->irc_fd);
poller_fd_reset (&self->irc_event);
+ xclose (self->irc_fd);
}
if (self->ssl)
SSL_free (self->ssl);
@@ -1585,13 +1585,11 @@ on_irc_disconnected (struct bot_context *ctx)
ctx->ssl_ctx = NULL;
}
+ poller_fd_reset (&ctx->irc_event);
xclose (ctx->irc_fd);
ctx->irc_fd = -1;
ctx->irc_registered = false;
- ctx->irc_event.closed = true;
- poller_fd_reset (&ctx->irc_event);
-
// TODO: inform plugins about the disconnect event
// All of our timers have lost their meaning now
--
cgit v1.2.3-70-g09d2