--------------------- PatchSet 10181 Date: 2007/11/30 15:25:51 Author: adri Branch: store_copy Tag: (none) Log: First pass for converting over the Vary code to use storeClientRef(). Members: src/store.c:1.49.4.1->1.49.4.2 Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.49.4.1 retrieving revision 1.49.4.2 diff -u -r1.49.4.1 -r1.49.4.2 --- squid/src/store.c 27 Nov 2007 08:12:29 -0000 1.49.4.1 +++ squid/src/store.c 30 Nov 2007 15:25:51 -0000 1.49.4.2 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.49.4.1 2007/11/27 08:12:29 adri Exp $ + * $Id: store.c,v 1.49.4.2 2007/11/30 15:25:51 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -845,17 +845,24 @@ } static void -storeLocateVaryRead(void *data, char *buf, ssize_t size) +storeLocateVaryRead(void *data, mem_node_ref nr, ssize_t size) { LocateVaryState *state = data; char *e; char *p = state->buf; size_t l = size + state->buf_offset; + const char *buf = nr.node->data; debug(11, 3) ("storeLocateVaryRead: %s %p seen_offset=%" PRINTF_OFF_T " buf_offset=%d size=%d\n", state->vary_data, data, state->seen_offset, (int) state->buf_offset, (int) size); if (size <= 0) { storeLocateVaryCallback(state); - return; + goto finish; } + assert(size <= nr.node->len); + /* size should never exceed what we asked for; just make sure first */ + assert(size + state->buf_offset <= state->buf_size); + /* Copy in the data before we do anything else */ + memcpy(state->buf + state->buf_offset, nr.node->data + nr.offset, size); + state->seen_offset = state->seen_offset + size; while ((e = memchr(p, '\n', l)) != NULL) { int l2; @@ -933,17 +940,18 @@ /* This does not look good. Bail out. This should match the size <= 0 case above */ debug(11, 1) ("storeLocateVaryRead: Buffer very large and still can't fit the data.. bailing out\n"); storeLocateVaryCallback(state); - return; + goto finish; } } debug(11, 3) ("storeLocateVaryRead: %p seen_offset=%" PRINTF_OFF_T " buf_offset=%d\n", data, state->seen_offset, (int) state->buf_offset); - storeClientCopy(state->sc, state->e, + storeClientRef(state->sc, state->e, state->seen_offset, state->seen_offset, state->buf_size - state->buf_offset, - state->buf + state->buf_offset, storeLocateVaryRead, state); +finish: + stmemNodeUnref(&nr); buf = 0; } void @@ -974,11 +982,10 @@ storeLocateVaryCallback(state); return; } - storeClientCopy(state->sc, state->e, + storeClientRef(state->sc, state->e, state->seen_offset, state->seen_offset, state->buf_size, - state->buf, storeLocateVaryRead, state); }