1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-10 11:35:07 -05:00

proper initialization of httprequest, no longer zeroing out twice

the whole 150000+ bytes struct, and also removing an equally big
additional buffer for pipelining treatment.
This commit is contained in:
Yang Tse 2008-02-05 02:21:38 +00:00
parent 7bd098f670
commit cd63a461d7

View File

@ -529,30 +529,37 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
int fail= FALSE; int fail= FALSE;
char *reqbuf = req->reqbuf; char *reqbuf = req->reqbuf;
char pipereq[REQBUFSIZ]; char *pipereq;
int pipereq_length; int pipereq_length = 0;
if(req->pipelining) { if(req->pipelining) {
pipereq = reqbuf + req->checkindex;
pipereq_length = req->offset - req->checkindex; pipereq_length = req->offset - req->checkindex;
memcpy(pipereq, reqbuf + req->checkindex, pipereq_length);
} }
else
pipereq_length = 0;
/*** Init the httpreqest structure properly for the upcoming request ***/ /*** Init the httpreqest structure properly for the upcoming request ***/
memset(req, 0, sizeof(struct httprequest));
/* here's what should not be 0 from the start */ req->checkindex = 0;
req->testno = DOCNUMBER_NOTHING; /* safe default */ req->offset = 0;
req->open = TRUE; /* connection should remain open and wait for more req->testno = DOCNUMBER_NOTHING;
commands */ req->partno = 0;
req->open = TRUE;
req->auth_req = FALSE;
req->auth = FALSE;
req->cl = 0;
req->digest = FALSE;
req->ntlm = FALSE;
req->pipe = 0; req->pipe = 0;
req->rcmd = RCMD_NORMALREQ;
req->prot_version = 0;
req->pipelining = FALSE;
/*** end of httprequest init ***/ /*** end of httprequest init ***/
while (req->offset < REQBUFSIZ) { while (req->offset < REQBUFSIZ) {
ssize_t got; ssize_t got;
if(pipereq_length) { if(pipereq_length) {
memcpy(reqbuf, pipereq, pipereq_length); memmove(reqbuf, pipereq, pipereq_length);
got = pipereq_length; got = pipereq_length;
pipereq_length = 0; pipereq_length = 0;
} }
@ -1001,17 +1008,13 @@ int main(int argc, char *argv[])
} }
#endif #endif
/* full initialization for new request after connection */ /* initialization of httprequest struct is done in get_request(), but due
memset(&req, 0, sizeof(req)); to pipelining treatment the pipelining struct field must be initialized
req.testno = DOCNUMBER_NOTHING; previously to FALSE every time a new connection arrives. */
req.open = TRUE;
req.auth_req = FALSE;
req.auth = FALSE;
req.digest = FALSE;
req.ntlm = FALSE;
req.pipelining = FALSE;
do { req.pipelining = FALSE;
do {
if(get_request(msgsock, &req)) if(get_request(msgsock, &req))
/* non-zero means error, break out of loop */ /* non-zero means error, break out of loop */
break; break;