--------------------- PatchSet 5014 Date: 2002/09/17 12:13:35 Author: rbcollins Branch: fixrange Tag: (none) Log: extract method for clientSocketContext - getTail Members: src/client_side.c:1.72.2.6->1.72.2.7 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.6 retrieving revision 1.72.2.7 diff -u -r1.72.2.6 -r1.72.2.7 --- squid/src/client_side.c 17 Sep 2002 12:00:00 -0000 1.72.2.6 +++ squid/src/client_side.c 17 Sep 2002 12:13:35 -0000 1.72.2.7 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.6 2002/09/17 12:00:00 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.7 2002/09/17 12:13:35 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -128,13 +128,20 @@ static DEFER httpAcceptDefer; static int clientRequestBodyTooLarge(int clen); static void clientProcessBody(ConnStateData * conn); +static clientStreamNode * getTail(clientSocketContext *); + +clientStreamNode * +getTail (clientSocketContext *context) +{ + return context->http->client_stream.tail->data; +} void clientSocketContextFree(void *data) { clientSocketContext *context = data; ConnStateData *conn = context->http->conn; - clientStreamNode *node = context->http->client_stream.tail->data; + clientStreamNode *node = getTail(context); /* We are *always* the tail - prevent recursive free */ assert(context == node->data); node->data = NULL; @@ -606,7 +613,7 @@ clientHttpRequest *http = context->http; StoreEntry *entry = http->entry; /* cheating: we are always the tail */ - clientStreamNode *node = http->client_stream.tail->data; + clientStreamNode *node = getTail (context); http->out.size += size; debug(33, 5) ("clientWriteComplete: FD %d, sz %ld, err %d, off %ld, len %d\n", fd, (long int) size, errflag, (long int) http->out.size, entry ? objectLen(entry) : 0); @@ -638,7 +645,7 @@ readBuffer.offset = http->out.offset; readBuffer.length = HTTP_REQBUF_SZ; readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, readBuffer); + clientStreamRead(getTail (context), http, readBuffer); break; } case STREAM_COMPLETE: @@ -1069,28 +1076,27 @@ http); if (parser_return_code < 0) { StoreIOBuffer readBuffer = EMPTYIOBUFFER; - clientStreamNode *node = http->client_stream.tail->prev->data; + clientStreamNode *node = getTail (context); debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); clientSetReplyToError(node->data, ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, NULL, &conn->peer.sin_addr, NULL, conn->in.buf, NULL); readBuffer.length = HTTP_REQBUF_SZ; readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, - readBuffer); + clientStreamRead(getTail (context), http, readBuffer); safe_free(prefix); break; } if ((request = urlParse(method, http->uri)) == NULL) { StoreIOBuffer readBuffer = EMPTYIOBUFFER; - clientStreamNode *node = http->client_stream.tail->prev->data; + clientStreamNode *node = getTail (context); debug(33, 5) ("Invalid URL: %s\n", http->uri); clientSetReplyToError(node->data, ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, &conn->peer.sin_addr, NULL, NULL, NULL); readBuffer.length = HTTP_REQBUF_SZ; readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, + clientStreamRead(getTail (context), http, readBuffer); safe_free(prefix); break; @@ -1132,7 +1138,7 @@ if (!urlCheckRequest(request) || httpHeaderHas(&request->header, HDR_TRANSFER_ENCODING)) { StoreIOBuffer readBuffer = EMPTYIOBUFFER; - clientStreamNode *node = http->client_stream.tail->prev->data; + clientStreamNode *node = getTail (context); clientSetReplyToError(node->data, ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED, request->method, NULL, &conn->peer.sin_addr, request, NULL, NULL); @@ -1163,15 +1169,13 @@ /* Is it too large? */ if (clientRequestBodyTooLarge(request->content_length)) { StoreIOBuffer readBuffer = EMPTYIOBUFFER; - clientStreamNode *node = - http->client_stream.tail->prev->data; + clientStreamNode *node = getTail (context); clientSetReplyToError(node->data, ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL, &conn->peer.sin_addr, http->request, NULL, NULL); readBuffer.length = HTTP_REQBUF_SZ; readBuffer.data = context->reqbuf; - clientStreamRead(http->client_stream.tail->data, http, - readBuffer); + clientStreamRead(getTail (context), http, readBuffer); break; } } @@ -1188,7 +1192,7 @@ clientStreamNode *node; context = parseHttpRequestAbort(conn, "error:request-too-large"); - node = context->http->client_stream.tail->prev->data; + node = getTail (context); 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", @@ -1202,8 +1206,7 @@ *S = context; readBuffer.length = HTTP_REQBUF_SZ; readBuffer.data = context->reqbuf; - clientStreamRead(context->http->client_stream.tail->data, - context->http, readBuffer); + clientStreamRead(getTail (context), context->http, readBuffer); return; } break; @@ -1367,8 +1370,7 @@ clientHttpRequest **H; clientStreamNode *node; clientHttpRequest *http = - parseHttpRequestAbort(conn, - "error:Connection%20lifetime%20expired"); + parseHttpRequestAbort(conn, "error:Connection%20lifetime%20expired"); node = http->client_stream.tail->prev->data; clientSetReplyToError(node->data, ERR_LIFETIME_EXP, HTTP_REQUEST_TIMEOUT, METHOD_NONE, "N/A", &conn->peer.sin_addr,