A more robust accept() handling. - 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 8eff8ae493a6f02e1a2b11cf69ac6cc84e4cace5
DIR parent b54cf16cabdb38610da974759ce274be20e480f0
HTML Author: Christoph Lohmann <20h@r-36.net>
Date: Mon, 28 Feb 2011 00:46:09 +0100
A more robust accept() handling.
Diffstat:
M main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
DIR diff --git a/main.c b/main.c
@@ -19,6 +19,7 @@
#include <time.h>
#include <pwd.h>
#include <grp.h>
+#include <errno.h>
#include "ind.h"
#include "handlr.h"
@@ -373,9 +374,15 @@ main(int argc, char *argv[])
while(running) {
sock = accept(list, (struct sockaddr *)&clt, &cltlen);
if(sock < 0) {
- perror("accept");
- close(list);
- return 1;
+ switch(errno) {
+ case ECONNABORTED:
+ case EINTR:
+ continue;
+ default:
+ perror("accept");
+ close(list);
+ return 1;
+ }
}
getnameinfo((struct sockaddr *)&clt, cltlen, clienth,