--------------------- PatchSet 10044 Date: 2007/09/29 16:41:12 Author: adri Branch: store_copy Tag: (none) Log: Ref'ify the errormap code. Members: src/errormap.c:1.4->1.4.12.1 Index: squid/src/errormap.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/errormap.c,v retrieving revision 1.4 retrieving revision 1.4.12.1 diff -u -r1.4 -r1.4.12.1 --- squid/src/errormap.c 21 Jan 2007 14:03:45 -0000 1.4 +++ squid/src/errormap.c 29 Sep 2007 16:41:12 -0000 1.4.12.1 @@ -81,7 +81,6 @@ store_client *sc; ERRMAPCB *callback; void *callback_data; - char *buf; } ErrorMapState; CBDATA_TYPE(ErrorMapState); @@ -95,7 +94,6 @@ state->e = NULL; requestUnlink(state->req); state->req = NULL; - memFree(state->buf, MEM_4K_BUF); cbdataUnlock(state->callback_data); state->callback_data = NULL; cbdataFree(state); @@ -110,10 +108,11 @@ } static void -errorMapFetchHeaders(void *data, char *buf, ssize_t size) +errorMapFetchHeaders(void *data, mem_node_ref nr, ssize_t size) { ErrorMapState *state = data; size_t hdr_size; + const char *buf = NULL; if (EBIT_TEST(state->e->flags, ENTRY_ABORTED)) goto abort; @@ -122,6 +121,8 @@ if (!cbdataValid(state->callback_data)) goto abort; + buf = nr.node->data + nr.offset; + if ((hdr_size = headersEnd(buf, size))) { http_status status; /* httpReplyParse(reply, buf, hdr_size); */ @@ -140,11 +141,13 @@ goto abort; } /* Need more data */ - storeClientCopy(state->sc, state->e, size, 0, 4096, state->buf, errorMapFetchHeaders, state); + storeClientRef(state->sc, state->e, size, 0, SM_PAGE_SIZE, errorMapFetchHeaders, state); done: + stmemNodeUnref(&nr); return; abort: errorMapFetchAbort(state); + stmemNodeUnref(&nr); return; } @@ -204,9 +207,8 @@ httpHeaderPutInt(&req->header, HDR_X_ERROR_STATUS, (int) reply->sline.status); httpHeaderPutStr(&req->header, HDR_X_REQUEST_URI, urlCanonical(client_req)); - state->buf = memAllocate(MEM_4K_BUF); fwdStart(-1, state->e, req); - storeClientCopy(state->sc, state->e, 0, 0, 4096, state->buf, errorMapFetchHeaders, state); + storeClientRef(state->sc, state->e, 0, 0, SM_PAGE_SIZE, errorMapFetchHeaders, state); return 1; }