------------------------------------------------------------ revno: 13746 revision-id: squid3@treenet.co.nz-20150206155958-vjemankvzysep68n parent: squid3@treenet.co.nz-20150206152624-gkz8imkb78eczo02 committer: Amos Jeffries branch nick: 3.5 timestamp: Fri 2015-02-06 07:59:58 -0800 message: Fix some cbdataFree related memory leaks The delete operator should have been called for these objects after previous code changes converted them to CBDATA_CLASS. As a result any member objects relying on their destructor to cleanup were being leaked. Also, make generic_cbdata::data a private member. The unwrap() method is easily used now. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20150206155958-vjemankvzysep68n # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 0bd80ba7b330915e1ffc3fcabe7a09f6f06a25ce # timestamp: 2015-02-06 16:51:07 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20150206152624-\ # gkz8imkb78eczo02 # # Begin patch === modified file 'src/cbdata.h' --- src/cbdata.h 2015-01-13 09:13:49 +0000 +++ src/cbdata.h 2015-02-06 15:59:58 +0000 @@ -426,6 +426,7 @@ delete this; } +private: /** * The wrapped data - only public to allow the mild abuse of this facility * done by store_swapout - it gives a wrapped StoreEntry to StoreIO as the === modified file 'src/neighbors.cc' --- src/neighbors.cc 2015-01-13 09:13:49 +0000 +++ src/neighbors.cc 2015-02-06 15:59:58 +0000 @@ -1447,8 +1447,7 @@ fake->abort(); // sets ENTRY_ABORTED and initiates releated cleanup HTTPMSGUNLOCK(fake->mem_obj->request); fake->unlock("peerCountMcastPeersDone"); - HTTPMSGUNLOCK(psstate->request); - cbdataFree(psstate); + delete psstate; } static void === modified file 'src/stat.cc' --- src/stat.cc 2015-01-13 09:13:49 +0000 +++ src/stat.cc 2015-02-06 15:59:58 +0000 @@ -370,11 +370,11 @@ storeAppendPrintf(state->sentry, "} by kid%d\n\n", KidIdentifier); state->sentry->complete(); state->sentry->unlock("statObjects+isDone"); - cbdataFree(state); + delete state; return; } else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) { state->sentry->unlock("statObjects+aborted"); - cbdataFree(state); + delete state; return; } else if (state->sentry->checkDeferRead(-1)) { state->sentry->flush(); === modified file 'src/store_swapout.cc' --- src/store_swapout.cc 2015-01-13 09:13:49 +0000 +++ src/store_swapout.cc 2015-02-06 15:59:58 +0000 @@ -89,8 +89,9 @@ static void storeSwapOutFileNotify(void *data, int errflag, StoreIOState::Pointer self) { - generic_cbdata *c = (generic_cbdata *)data; - StoreEntry *e = (StoreEntry *)c->data; + StoreEntry *e; + static_cast(data)->unwrap(&e); + MemObject *mem = e->mem_obj; assert(e->swap_status == SWAPOUT_WRITING); assert(mem); @@ -281,12 +282,12 @@ static void storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) { - generic_cbdata *c = (generic_cbdata *)data; - StoreEntry *e = (StoreEntry *)c->data; + StoreEntry *e; + static_cast(data)->unwrap(&e); + MemObject *mem = e->mem_obj; assert(mem->swapout.sio == self); assert(e->swap_status == SWAPOUT_WRITING); - cbdataFree(c); // if object_size is still unknown, the entry was probably aborted if (errflag || e->objectLen() < 0) {