Adding proper socket handling. We don't need REUSE. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 0e66ab01eb5b38b5013f75d22e4ca0779c8d45a0 DIR parent 63cd2d298843b1f144252f1902a7e1890000e1d7 HTML 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: M main.c | 13 +++++-------- M rc.d/Archlinux.rc.d | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) --- DIR 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); DIR 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