commit 0e66ab01eb5b38b5013f75d22e4ca0779c8d45a0
parent 63cd2d298843b1f144252f1902a7e1890000e1d7
Author: Christoph Lohmann <20h@r-36.net>
Date: Tue, 8 Mar 2011 14:08:58 +0100
Adding proper socket handling. We don't need REUSE.
Diffstat:
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/main.c b/main.c
@@ -215,8 +215,10 @@ sighandler(int sig)
case SIGKILL:
if(logfile != nil)
stoplogging(glfd);
- if(listfd >= 0)
+ if(listfd >= 0) {
+ shutdown(listfd, SHUT_RDWR);
close(listfd);
+ }
exit(EXIT_SUCCESS);
break;
default:
@@ -359,13 +361,6 @@ main(int argc, char *argv[])
}
freeaddrinfo(ai);
- opt = 1;
- if(setsockopt(listfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) {
- perror("setsockopt");
- close(listfd);
- return 1;
- }
-
if(listen(listfd, 255)) {
perror("listen");
close(listfd);
@@ -388,6 +383,7 @@ main(int argc, char *argv[])
case ECONNABORTED:
case EINTR:
if (!running) {
+ shutdown(listfd, SHUT_RDWR);
close(listfd);
return 0;
}
@@ -419,6 +415,7 @@ main(int argc, char *argv[])
}
}
+ shutdown(listfd, SHUT_RDWR);
close(listfd);
if(logfile != nil)
stoplogging(glfd);
diff --git a/rc.d/Archlinux.rc.d b/rc.d/Archlinux.rc.d
@@ -18,7 +18,7 @@ case "$1" in
;;
stop)
stat_busy "Stopping geomyidae"
- [ ! -z "$PID" ] && kill -KILL $PID &>/dev/null
+ [ ! -z "$PID" ] && kill $PID &>/dev/null
if [ $? -gt 0 ]; then
stat_fail
else