--------------------- PatchSet 10177 Date: 2007/11/30 04:16:51 Author: adri Branch: store_copy Tag: (none) Log: update the storeUpdate* routines to use storeClientRef() Members: src/store_update.c:1.2.4.2->1.2.4.3 Index: squid/src/store_update.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_update.c,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.3 diff -u -r1.2.4.2 -r1.2.4.3 --- squid/src/store_update.c 27 Nov 2007 08:12:29 -0000 1.2.4.2 +++ squid/src/store_update.c 30 Nov 2007 04:16:51 -0000 1.2.4.3 @@ -1,6 +1,6 @@ /* - * $Id: store_update.c,v 1.2.4.2 2007/11/27 08:12:29 adri Exp $ + * $Id: store_update.c,v 1.2.4.3 2007/11/30 04:16:51 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Henrik Nordstrom @@ -49,7 +49,6 @@ StoreEntry *newentry; store_client *sc; squid_off_t offset; - char buf[4096]; } StoreUpdateState; CBDATA_TYPE(StoreUpdateState); @@ -87,40 +86,46 @@ } static void -storeUpdateCopy(void *data, char *buf, ssize_t size) +storeUpdateCopy(void *data, mem_node_ref nr, ssize_t size) { + const char *buf = nr.node->data + nr.offset; + assert(size <= nr.node->len - nr.offset); StoreUpdateState *state = data; if (EBIT_TEST(state->newentry->flags, ENTRY_ABORTED)) { debug(20, 1) ("storeUpdateCopy: Aborted at %d (%d)\n", (int) state->offset, (int) size); /* the abort callback deals with the needed cleanup */ - return; + goto finish; } if (EBIT_TEST(state->newentry->flags, KEY_PRIVATE) && state->newentry->mem_obj->nclients == 0) { debug(20, 2) ("storeUpdateCopy: Gone stale with no clients, skip copying of the rest\n"); storeUpdateDone(state); - return; + goto finish; } if (size < 0) { debug(20, 1) ("storeUpdateCopy: Error at %d (%d)\n", (int) state->offset, (int) size); storeUpdateDone(state); - return; + goto finish; } if (size > 0) { storeAppend(state->newentry, buf, size); if (EBIT_TEST(state->newentry->flags, ENTRY_ABORTED)) { debug(20, 1) ("storeUpdateCopy: Aborted on write at %d (%d)\n", (int) state->offset, (int) size); - return; + goto finish; } state->offset += size; - storeClientCopy(state->sc, state->oldentry, state->offset, state->offset, sizeof(state->buf), state->buf, storeUpdateCopy, state); - return; + storeClientRef(state->sc, state->oldentry, state->offset, state->offset, SM_PAGE_SIZE, storeUpdateCopy, state); + goto finish; } else { storeComplete(state->newentry); storeUnlockObject(state->newentry); state->newentry = NULL; storeUpdateDone(state); } + +finish: + buf = NULL; + stmemNodeUnref(&nr); } void @@ -182,6 +187,6 @@ debug(20, 1) ("storeUpdate: Aborted on write\n"); return; } - storeClientCopy(state->sc, state->oldentry, state->offset, state->offset, sizeof(state->buf), state->buf, storeUpdateCopy, state); + storeClientRef(state->sc, state->oldentry, state->offset, state->offset, SM_PAGE_SIZE, storeUpdateCopy, state); return; }