]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Free control memory on fork
authorRoy Marples <roy@marples.name>
Sat, 4 Oct 2014 08:22:09 +0000 (08:22 +0000)
committerRoy Marples <roy@marples.name>
Sat, 4 Oct 2014 08:22:09 +0000 (08:22 +0000)
control.c
dhcpcd.c

index 5c655806ff559cfd29a0d57a2133764323c53348..c92a8e546df980a95f629fd685de7fa6c6f0bf56 100644 (file)
--- a/control.c
+++ b/control.c
@@ -298,6 +298,9 @@ control_stop(struct dhcpcd_ctx *ctx)
        int retval = 0;
        struct fd_list *l;
 
+       if (ctx->options & DHCPCD_FORKED)
+               goto freeit;
+
        if (ctx->control_fd == -1)
                return 0;
        eloop_event_delete(ctx->eloop, ctx->control_fd, 0);
@@ -314,6 +317,7 @@ control_stop(struct dhcpcd_ctx *ctx)
                        retval = -1;
        }
 
+freeit:
        while ((l = TAILQ_FIRST(&ctx->control_fds))) {
                TAILQ_REMOVE(&ctx->control_fds, l, next);
                eloop_event_delete(ctx->eloop, l->fd, 0);
index 69af3e29ec949159b94d2f560ba4c8b9d5139459..e15b533520b2284fd9fae7a3c84c0acc348194ef 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1726,7 +1726,7 @@ exit1:
        ipv4_ctxfree(&ctx);
        ipv6_ctxfree(&ctx);
        dev_stop(&ctx, !(ctx.options & DHCPCD_FORKED));
-       if (!(ctx.options & DHCPCD_FORKED) && control_stop(&ctx) == -1)
+       if (control_stop(&ctx) == -1)
                syslog(LOG_ERR, "control_stop: %m:");
        if (ctx.pid_fd != -1) {
                close(ctx.pid_fd);