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.
This commit is contained in:
Přemysl Eric Janouch 2017-05-06 21:35:44 +02:00
parent ec842db0fb
commit c3d62b8799
Signed by: p
GPG Key ID: B715679E3A361BE6
3 changed files with 7 additions and 13 deletions

View File

@ -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);
}

7
kike.c
View File

@ -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);

View File

@ -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