Ensure we remove the socket from the eloop event queue before closing it.

This commit is contained in:
Roy Marples 2014-02-12 10:29:06 +00:00
parent 60dad20dbd
commit e9882fb08a
6 changed files with 9 additions and 7 deletions

View File

@ -58,8 +58,8 @@ control_remove(void *arg)
while (l) {
n = l->next;
if (l == arg) {
close(l->fd);
eloop_event_delete(ctx->eloop, l->fd);
close(l->fd);
if (last == NULL)
ctx->control_fds = l->next;
else

2
dev.c
View File

@ -62,8 +62,8 @@ dev_stop(struct dhcpcd_ctx *ctx, int stop)
if (ctx->dev) {
if (stop)
syslog(LOG_DEBUG, "dev: unloaded %s", ctx->dev->name);
ctx->dev->stop();
eloop_event_delete(ctx->eloop, ctx->dev_fd);
ctx->dev->stop();
free(ctx->dev);
ctx->dev = NULL;
ctx->dev_fd = -1;

2
dhcp.c
View File

@ -2739,8 +2739,8 @@ dhcp_free(struct interface *ifp)
}
if (ifp == NULL) {
if (ctx->udp_fd != -1) {
close(ctx->udp_fd);
eloop_event_delete(ctx->eloop, ctx->udp_fd);
close(ctx->udp_fd);
ctx->udp_fd = -1;
}

View File

@ -2672,8 +2672,8 @@ dhcp6_freedrop(struct interface *ifp, int drop, const char *reason)
}
if (ifp == NULL) {
if (ctx->ipv6->dhcp_fd != -1) {
close(ctx->ipv6->dhcp_fd);
eloop_event_delete(ctx->eloop, ctx->ipv6->dhcp_fd);
close(ctx->ipv6->dhcp_fd);
ctx->ipv6->dhcp_fd = -1;
}
}

View File

@ -1480,8 +1480,10 @@ exit1:
free(ctx.ifaces);
}
free(ctx.duid);
if (ctx.link_fd != -1)
if (ctx.link_fd != -1) {
eloop_event_delete(ctx.eloop, ctx.link_fd);
close(ctx.link_fd);
}
free_options(ifo);
free_globals(&ctx);

View File

@ -235,8 +235,8 @@ unspec:
eexit:
if (ctx->nd_fd != -1) {
close(ctx->nd_fd);
eloop_event_delete(dctx->eloop, ctx->nd_fd);
close(ctx->nd_fd);
ctx->nd_fd = -1;
}
#ifdef IPV6_SEND_DAD
@ -418,8 +418,8 @@ ipv6nd_free(struct interface *ifp)
}
if (ifp == NULL) {
if (ctx->ipv6->nd_fd != -1) {
close(ctx->ipv6->nd_fd);
eloop_event_delete(ctx->eloop, ctx->ipv6->nd_fd);
close(ctx->ipv6->nd_fd);
ctx->ipv6->nd_fd = -1;
}
}