]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we free the last ARP state, close the ARP socket.
authorRoy Marples <roy@marples.name>
Fri, 19 Jun 2015 13:17:10 +0000 (13:17 +0000)
committerRoy Marples <roy@marples.name>
Fri, 19 Jun 2015 13:17:10 +0000 (13:17 +0000)
arp.c

diff --git a/arp.c b/arp.c
index e381b42ebfeca876a3f9c26ede657368342d3a7f..46b6789d4043819da9d542fb292579f3f1198981 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -349,6 +349,15 @@ arp_free(struct arp_state *astate)
                state = D_STATE(astate->iface);
                TAILQ_REMOVE(&state->arp_states, astate, next);
                free(astate);
+
+               /* If there are no more ARP states, close the socket. */
+               if (state->arp_fd != -1 &&
+                   TAILQ_FIRST(&state->arp_states) == NULL)
+               {
+                       eloop_event_delete(ifp->ctx->eloop, state->arp_fd);
+                       close(state->arp_fd);
+                       state->arp_fd = -1;
+               }
        }
 }