]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We should shutdown instead of close our sockets to inform clients they have gone.
authorRoy Marples <roy@marples.name>
Thu, 15 Jan 2009 14:50:19 +0000 (14:50 +0000)
committerRoy Marples <roy@marples.name>
Thu, 15 Jan 2009 14:50:19 +0000 (14:50 +0000)
control.c

index 1e6141457189a2887aab6623f18ff0009b035f3e..e280e3f21e291fa6f4624ac6e128ac1473213093 100644 (file)
--- a/control.c
+++ b/control.c
@@ -54,7 +54,7 @@ remove_control_data(void *arg)
 
        for (l = fds; l != NULL; l = l->next) {
                if (l == arg) {
-                       close(l->fd);
+                       shutdown(l->fd, SHUT_RDWR);
                        delete_event(l->fd);
                        if (last == NULL)
                                fds = l->next;
@@ -152,19 +152,21 @@ stop_control(void)
        struct fd_list *l, *ll;
 
        delete_event(fd);
+       if (shutdown(fd, SHUT_RDWR) == -1)
+               retval = 1;
+       fd = -1;
+       if (unlink(CONTROLSOCKET) == -1)
+               retval = -1;
+
        l = fds;
        while (l != NULL) {
                ll = l->next;
                delete_event(l->fd);
-               close(l->fd);
+               shutdown(l->fd, SHUT_RDWR);
                free(l);
                l = ll;
        }
-       if (close(fd) == -1)
-               retval = 1;
-       fd = -1;
-       if (unlink(CONTROLSOCKET) == -1)
-               retval = -1;
+
        return retval;
 }