--------------------- PatchSet 10392 Date: 2008/01/13 12:24:37 Author: adri Branch: s27_adri Tag: (none) Log: Shuffle the parser code in TryParseRequest() around. Move the error condition to the top of the function and have it exit early in case of error. This simplifies the code path slightly. The aim is to move the call to clientCheckFollowXForwardedFor() right at the end of the function so I can eventually move it -out- of the function and into the caller. This is part of restructuring the client-side buffer management mess. Members: src/client_side.c:1.202.2.9.4.28->1.202.2.9.4.29 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.28 retrieving revision 1.202.2.9.4.29 diff -u -r1.202.2.9.4.28 -r1.202.2.9.4.29 --- squid/src/client_side.c 13 Jan 2008 12:15:43 -0000 1.202.2.9.4.28 +++ squid/src/client_side.c 13 Jan 2008 12:24:37 -0000 1.202.2.9.4.29 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.28 2008/01/13 12:15:43 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.29 2008/01/13 12:24:37 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -3935,11 +3935,35 @@ fd_note_static(conn->fd, "Reading next request"); /* Process request */ http = parseHttpRequest(conn, &msg, &method, &parser_return_code); - if (!http) { - /* falls through here to the "if parser_return_code == 0"; not sure what will - * happen if http == NULL and parser_return_code != 0 .. */ + if (parser_return_code == 0) { + /* the old code assumed this -adrian */ + assert(!http); + + /* + * Partial request received; reschedule until parseHttpRequest() + * is happy with the input + */ + if (conn->in.offset >= Config.maxRequestHeaderSize) { + /* The request is too large to handle */ + debug(33, 1) ("Request header is too large (%d bytes)\n", + (int) conn->in.offset); + debug(33, 1) ("Config 'request_header_max_size'= %ld bytes.\n", + (long int) Config.maxRequestHeaderSize); + err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_URI_TOO_LONG, NULL); + err->src_addr = conn->peer.sin_addr; + http = parseHttpRequestAbort(conn, "error:request-too-large"); + /* add to the client request queue */ + dlinkAddTail(http, &http->node, &conn->reqs); + http->log_type = LOG_TCP_DENIED; + http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); + errorAppendEntry(http->entry, err); + return -1; + } + return 0; } - if (http) { + /* the old code assumed this -adrian */ + assert(http); + /* add to the client request queue */ dlinkAddTail(http, &http->node, &conn->reqs); conn->nrequests++; @@ -4076,29 +4100,6 @@ } else { clientCheckFollowXForwardedFor(http); } - } else if (parser_return_code == 0) { - /* - * Partial request received; reschedule until parseHttpRequest() - * is happy with the input - */ - if (conn->in.offset >= Config.maxRequestHeaderSize) { - /* The request is too large to handle */ - debug(33, 1) ("Request header is too large (%d bytes)\n", - (int) conn->in.offset); - debug(33, 1) ("Config 'request_header_max_size'= %ld bytes.\n", - (long int) Config.maxRequestHeaderSize); - err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_URI_TOO_LONG, NULL); - err->src_addr = conn->peer.sin_addr; - http = parseHttpRequestAbort(conn, "error:request-too-large"); - /* add to the client request queue */ - dlinkAddTail(http, &http->node, &conn->reqs); - http->log_type = LOG_TCP_DENIED; - http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); - errorAppendEntry(http->entry, err); - return -1; - } - return 0; - } if (!cbdataValid(conn)) return -1;