From: Roy Marples Date: Wed, 12 Feb 2014 10:29:06 +0000 (+0000) Subject: Ensure we remove the socket from the eloop event queue before closing it. X-Git-Tag: v6.3.0~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9882fb08a128b28c7fd1a203bfff0db911ce0cc;p=thirdparty%2Fdhcpcd.git Ensure we remove the socket from the eloop event queue before closing it. --- diff --git a/control.c b/control.c index 66883272..6e47d63a 100644 --- a/control.c +++ b/control.c @@ -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 diff --git a/dev.c b/dev.c index 0ace151d..a693b91c 100644 --- a/dev.c +++ b/dev.c @@ -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; diff --git a/dhcp.c b/dhcp.c index 5ada1565..fb642d39 100644 --- a/dhcp.c +++ b/dhcp.c @@ -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; } diff --git a/dhcp6.c b/dhcp6.c index 4eb99541..6dcd5ef3 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -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; } } diff --git a/dhcpcd.c b/dhcpcd.c index 0a684c73..51e4525b 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -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); diff --git a/ipv6nd.c b/ipv6nd.c index a4300be9..8b8f52fa 100644 --- a/ipv6nd.c +++ b/ipv6nd.c @@ -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; } }