X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fhtparser.c;h=07f3dd67daa8b20088f390dd4009b108b487e35d;hb=a06a2fbdf3cd4dc4728c437304478184902e3aa8;hp=6382bf2b0435b21a26e5b8952ee479d50e23ac47;hpb=83723896cdbe2fb064748e45611e9b9c829c1d72;p=ashd.git diff --git a/src/htparser.c b/src/htparser.c index 6382bf2..07f3dd6 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -300,6 +300,7 @@ static void serve(struct muth *muth, va_list args) vavar(int, fd); vavar(struct sockaddr_storage, name); int cfd; + int pfds[2]; char old; char *hd, *p; struct charbuf inbuf, outbuf; @@ -350,16 +351,24 @@ static void serve(struct muth *muth, va_list args) headappheader(req, "X-Ash-Address", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&name)->sin6_addr, nmbuf, sizeof(nmbuf))); headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in6 *)&name)->sin6_port))); } - if((cfd = sendreq(plex, req)) < 0) + if(block(plex, EV_WRITE, 60) <= 0) goto out; + if(socketpair(PF_UNIX, SOCK_STREAM, 0, pfds)) + goto out; + if(sendreq(plex, req, pfds[0])) + goto out; + close(pfds[0]); + cfd = pfds[1]; /* * If there is message data, pass it: */ if((hd = getheader(req, "content-length")) != NULL) { dlen = atoo(hd); - if(dlen > 0) - passdata(fd, cfd, &inbuf, dlen); + if(dlen > 0) { + if(passdata(fd, cfd, &inbuf, dlen) < 0) + goto out; + } } /* Make sure to send EOF */ shutdown(cfd, SHUT_WR); @@ -379,7 +388,8 @@ static void serve(struct muth *muth, va_list args) * Pass the actual output: */ sizebuf(outbuf, 65536); - sent = passdata(cfd, fd, &outbuf, -1); + if((sent = passdata(cfd, fd, &outbuf, -1)) < 0) + goto out; sent -= headoff; /*