X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=src%2Fuserplex.c;fp=src%2Fuserplex.c;h=48a8ed3287c27879ab7c804aa4ea91c264f4117d;hp=c50a15c84586b86ac4aef34a6626bd2041dcf110;hb=bcad6b0c48d516ddc920b52f06083ceaa242e1ca;hpb=589987f8218c9aa61d65f582a3b3e1bbd32bda81 diff --git a/src/userplex.c b/src/userplex.c index c50a15c..48a8ed3 100644 --- a/src/userplex.c +++ b/src/userplex.c @@ -158,19 +158,24 @@ static int forkchild(char *usrnm, struct hthead *forreq, int reqfd) static void serve2(struct user *usr, struct hthead *req, int fd) { + int serr; + if(usr->fd < 0) usr->fd = forkchild(usr->name, req, fd); - if(sendreq(usr->fd, req, fd)) { - if((errno == EPIPE) || (errno == ECONNRESET)) { + if(sendreq2(usr->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) { + serr = errno; + if((serr == EPIPE) || (serr == ECONNRESET)) { /* Assume that the child has crashed and restart it. */ close(usr->fd); usr->fd = forkchild(usr->name, req, fd); - if(!sendreq(usr->fd, req, fd)) + if(!sendreq2(usr->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) return; } - flog(LOG_ERR, "could not pass on request to user `%s': %s", usr->name, strerror(errno)); - close(usr->fd); - usr->fd = -1; + flog(LOG_ERR, "could not pass on request to user `%s': %s", usr->name, strerror(serr)); + if(serr != EAGAIN) { + close(usr->fd); + usr->fd = -1; + } } }