X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fcf.c;h=ba63999eba44303f36905866281335dbce7159c7;hb=518c678c21a99f4b148f3cb1f40afe8b51577082;hp=38d98081a260e833c326fd782b3e68e9b2cb817e;hpb=1924fe8c26de2861744fd576631ad15da2759f51;p=ashd.git diff --git a/lib/cf.c b/lib/cf.c index 38d9808..ba63999 100644 --- a/lib/cf.c +++ b/lib/cf.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef HAVE_CONFIG_H @@ -305,21 +306,25 @@ static struct chandler stdhandler = { static int stdhandle(struct child *ch, struct hthead *req, int fd, void (*chinit)(void *), void *idata) { struct stdchild *i = ch->pdata; + int serr; if(i->type == CH_SOCKET) { if(i->fd < 0) i->fd = stdmkchild(i->argv, chinit, idata); - if(sendreq(i->fd, req, fd)) { - if((errno == EPIPE) || (errno == ECONNRESET)) { + if(sendreq2(i->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) { + serr = errno; + if((serr == EPIPE) || (serr == ECONNRESET)) { /* Assume that the child has crashed and restart it. */ close(i->fd); i->fd = stdmkchild(i->argv, chinit, idata); - if(!sendreq(i->fd, req, fd)) + if(!sendreq2(i->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT)) return(0); } - flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(errno)); - close(i->fd); - i->fd = -1; + flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(serr)); + if(serr != EAGAIN) { + close(i->fd); + i->fd = -1; + } return(-1); } } else if(i->type == CH_FORK) {