]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure we remove the socket from the eloop event queue before closing it.
authorRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 10:29:06 +0000 (10:29 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 10:29:06 +0000 (10:29 +0000)
control.c
dev.c
dhcp.c
dhcp6.c
dhcpcd.c
ipv6nd.c

index 6688327230d0bcedb9fe61876e5303eb508e0b51..6e47d63afde701eeb9d50bca1ed1966bf9e3367c 100644 (file)
--- 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 0ace151d58ae152b35cda2f755d1ad31ff7b6412..a693b91c2083b5f73fb2ba077b04cc2fd0b19144 100644 (file)
--- 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 5ada15650ee830f2fdd010fb8d0404698c63849b..fb642d3998449d87e448bf3f4e116f9772f5b25a 100644 (file)
--- 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 4eb99541933170980becd874780ff4a3c8cb9b08..6dcd5ef3ee2e626ad31b795e7793ec62cce92019 100644 (file)
--- 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;
                }
        }
index 0a684c73ddf665e82b85c64f4b0954a11be3a147..51e4525b5006c10caa41fb4ee1bbeaa5128ba36c 100644 (file)
--- 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);
index a4300be9e1e7296889469e5f092ccb5b00489b97..8b8f52fa35996d85ae4fb1de5b9a0f0953c6ede7 100644 (file)
--- 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;
                }
        }