From: Roy Marples Date: Thu, 15 Jan 2009 14:50:19 +0000 (+0000) Subject: We should shutdown instead of close our sockets to inform clients they have gone. X-Git-Tag: v5.0.0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad22dab30ac6653b27b9971100ace375bb067d84;p=thirdparty%2Fdhcpcd.git We should shutdown instead of close our sockets to inform clients they have gone. --- diff --git a/control.c b/control.c index 1e614145..e280e3f2 100644 --- 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; }