Newer
Older
Daniel Stenberg
committed
/* not a fork, just set rc so the following proceeds nicely */
rc = 0;
/* 0 is returned to the child */
if(0 == rc) {
#endif
#ifdef TCP_NODELAY
/*
* Disable the Nagle algorithm to make it easier to send out a large
* response in many small segments to torture the clients more.
*/
flag = 1;
if (setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY,
(void *)&flag, sizeof(flag)) == -1) {
logmsg("====> TCP_NODELAY failed");
}
/* initialization of httprequest struct is done in get_request(), but due
to pipelining treatment the pipelining struct field must be initialized
previously to FALSE every time a new connection arrives. */
req.pipelining = FALSE;
do {
Daniel Stenberg
committed
if(get_request(msgsock, &req))
/* non-zero means error, break out of loop */
break;
Daniel Stenberg
committed
if(prevbounce) {
/* bounce treatment requested */
if((req.testno == prevtestno) &&
(req.partno == prevpartno)) {
req.partno++;
logmsg("BOUNCE part number to %ld", req.partno);
}
else {
prevbounce = FALSE;
prevtestno = -1;
prevpartno = -1;
}
Daniel Stenberg
committed
}
Daniel Stenberg
committed
send_doc(msgsock, &req);
Daniel Stenberg
committed
if((req.testno < 0) && (req.testno != DOCNUMBER_CONNECT)) {
logmsg("special request received, no persistancy");
break;
}
Daniel Stenberg
committed
if(!req.open) {
logmsg("instructed to close connection after server-reply");
break;
}
Daniel Stenberg
committed
if(req.open)
logmsg("=> persistant connection request ended, awaits new request");
/* if we got a CONNECT, loop and get another request as well! */
Daniel Stenberg
committed
} while(req.open || (req.testno == DOCNUMBER_CONNECT));
sclose(msgsock);
Daniel Stenberg
committed
if (req.testno == DOCNUMBER_QUIT)
break;
#ifdef CURL_SWS_FORK_ENABLED
}
#endif
sclose(sock);