--------------------- PatchSet 4704 Date: 2002/08/16 08:33:00 Author: rbcollins Branch: esi Tag: (none) Log: fix up esi buffering to deal with stream changes Members: src/ESI.c:1.1.2.9->1.1.2.10 src/client_side_reply.c:1.1.2.13->1.1.2.14 src/stmem.c:1.7->1.7.32.1 src/store_client.c:1.13.4.1->1.13.4.2 Index: squid/src/ESI.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ESI.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid/src/ESI.c 16 Aug 2002 01:12:32 -0000 1.1.2.9 +++ squid/src/ESI.c 16 Aug 2002 08:33:00 -0000 1.1.2.10 @@ -1,6 +1,6 @@ /* - * $Id: ESI.c,v 1.1.2.9 2002/08/16 01:12:32 rbcollins Exp $ + * $Id: ESI.c,v 1.1.2.10 2002/08/16 08:33:00 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -150,7 +150,7 @@ esiSegment *temp = context->outbound->next; /* remove the used buffer */ context->outbound_offset = 0; - cbdataReferenceDone (context->outbound); + cbdataFree (context->outbound); context->outbound = temp; } context->pos += len; @@ -199,6 +199,11 @@ cbdataReferenceDone (context); return clientStreamStatus (this, http); } + if (context->flags.oktosend && context->flags.finished && + !(context->outbound && context->outbound_offset < context->outbound->len)) { + cbdataReferenceDone (context); + return STREAM_UNPLANNED_COMPLETE; /* we don't know lengths in advance */ + } /* ?? RC: we can't be aborted / fail ? */ return STREAM_NONE; } @@ -306,9 +311,11 @@ if (body_data) { assert (body_size <= HTTP_REQBUF_SZ); + debug (86,1 )("ESIProcessStream found %u bytes of body data at offset %ld\n", body_size, this->readoff); /* secure the data for later use */ if (!context->incoming) { /* create a new buffer segment */ + debug (86,1) ("esiProcessStream: Setting up incoming buffer\n"); CBDATA_INIT_TYPE(esiSegment); context->buffered = cbdataAlloc (esiSegment); context->incoming = context->buffered; @@ -317,6 +324,8 @@ /* We have to copy the data out because we didn't supply this buffer */ size_t space = HTTP_REQBUF_SZ - context->incoming->len; size_t len = space < body_size ? space : body_size; + debug (86,1)("Copying data from %p to %p because our buffer was not used\n", body_data, + &context->incoming->buf[context->incoming->len]); xmemcpy (&context->incoming->buf[context->incoming->len], body_data, len); context->incoming->len += len; if (context->incoming->len == HTTP_REQBUF_SZ) { @@ -372,55 +381,15 @@ /* ok.. no data sent, try to pull more data in from upstream. * FIXME: Don't try this if we have finished reading the template */ -// assert (context->incoming && context->incoming->len < HTTP_REQBUF_SZ); -// clientStreamRead (this, http, context->readpos, context->incoming->len - HTTP_REQBUF_SZ, -// &context->incoming->buf[context->incoming->len]); -// - esiFail (this, context, http); + assert (context->incoming && context->incoming->len < HTTP_REQBUF_SZ); + clientStreamRead (this, http, context->readpos, HTTP_REQBUF_SZ - context->incoming->len, + &context->incoming->buf[context->incoming->len]); + +// esiFail (this, context, http); cbdataReferenceDone (context); #if 0 - /* no data to send. Try to generate some */ - - if (body_data) { - assert (body_size <= HTTP_REQBUF_SZ); - /* secure the data for later use */ - if (!context->incoming) { - /* create a new buffer segment */ - CBDATA_INIT_TYPE(esiSegment); - context->buffered = cbdataAlloc (esiSegment); - context->incoming = context->buffered; - } - if (body_data != &context->incoming->buf[context->incoming->len]) { - /* We have to copy the data out because we didn't supply this buffer */ - size_t space = HTTP_REQBUF_SZ - context->incoming->len; - xmemcpy (&context->incoming->buf[context->incoming->len], body_data, space); - context->incoming->len += space; - if (context->incoming->len == HTTP_REQBUF_SZ) { - /* append another buffer */ - context->incoming->next = cbdataAlloc (esiSegment); - context->incoming = context->incoming->next; - } - if (space != body_size) { - /* capture the remnants */ - xmemcpy (context->incoming->buf, &body_data[space], body_size - space); - context->incoming->len = body_size - space; - } - } else { - /* update our position counters, and if needed assign a new buffer */ - context->incoming->len += body_size; - assert (context->incoming->len <= HTTP_REQBUF_SZ); - if (context->incoming->len > HTTP_REQBUF_SZ / 2) { - /* allocate a new buffer */ - context->incoming->next = cbdataAlloc (esiSegment); - context->incoming = context->incoming->next; - } - } - } - - debug(86, 0) ("clientSendMoreData: Will be checking for ESI content here - %d sub requests remaining\n", context->remaining_esi_requests); - /* HACK to test buffering */ /* EOF / Read error / aborted entry */ if (rep == NULL && body_data == NULL && body_size == 0) { Index: squid/src/client_side_reply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_reply.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid/src/client_side_reply.c 16 Aug 2002 01:12:32 -0000 1.1.2.13 +++ squid/src/client_side_reply.c 16 Aug 2002 08:33:00 -0000 1.1.2.14 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.1.2.13 2002/08/16 01:12:32 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.1.2.14 2002/08/16 08:33:00 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1394,7 +1394,7 @@ } /* ESI TODO: replace me with a true ESI header check */ if (http->flags.accel && rep->sline.status != HTTP_FORBIDDEN && - !clientAlwaysAllowResponse(rep->sline.status) && strstr (http->uri, "esi")) { + !clientAlwaysAllowResponse(rep->sline.status) && !strcmp (http->uri, "http://192.168.0.2:9673/esi_page_1.html")) { debug(88, 0) ("Enabling ESI processing for %s\n", http->uri); clientStreamInsertHead (&http->client_stream, esiStreamRead, esiProcessStream, esiStreamStatus,NULL); Index: squid/src/stmem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stmem.c,v retrieving revision 1.7 retrieving revision 1.7.32.1 diff -u -r1.7 -r1.7.32.1 --- squid/src/stmem.c 24 Oct 2001 09:42:13 -0000 1.7 +++ squid/src/stmem.c 16 Aug 2002 08:33:00 -0000 1.7.32.1 @@ -1,6 +1,6 @@ /* - * $Id: stmem.c,v 1.7 2001/10/24 09:42:13 squidadm Exp $ + * $Id: stmem.c,v 1.7.32.1 2002/08/16 08:33:00 rbcollins Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -133,9 +133,10 @@ char *ptr_to_buf = NULL; int bytes_from_this_packet = 0; int bytes_into_this_packet = 0; - debug(19, 6) ("memCopy: offset %ld: size %d\n", (long int) offset, (int) size); + debug(19, 6) ("memCopy: offset %ld: size %u\n", (long int) offset, size); if (p == NULL) return 0; + /* RC: the next assert is useless */ assert(size > 0); /* Seek our way into store */ while ((t_off + p->len) < offset) { Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.13.4.1 retrieving revision 1.13.4.2 diff -u -r1.13.4.1 -r1.13.4.2 --- squid/src/store_client.c 14 Aug 2002 11:16:06 -0000 1.13.4.1 +++ squid/src/store_client.c 16 Aug 2002 08:33:00 -0000 1.13.4.2 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.13.4.1 2002/08/14 11:16:06 rbcollins Exp $ + * $Id: store_client.c,v 1.13.4.2 2002/08/16 08:33:00 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -182,6 +182,7 @@ void *data) { assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); + assert (size < 4097); /* ESI FIXME: remove this */ debug(20, 3) ("storeClientCopy: %s, want %d, size %d, cb %p, cbdata %p\n", storeKeyText(e->hash.key), (int) copy_offset,