This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 247696b39c6cfbc4abaccd7f331c48597cd9a2d2 Author: Chris McFarlen <[email protected]> AuthorDate: Wed May 29 12:28:55 2024 -0500 Make sure to use proper allocator to free (#11381) * Make sure to use proper allocator to free * more incorrect free use --------- Co-authored-by: Chris McFarlen <[email protected]> (cherry picked from commit 9158a02f2b61b6c46c99e535026a699af55d611b) --- src/iocore/cache/CacheDir.cc | 2 +- src/iocore/cache/CacheEvacuateDocVC.cc | 8 ++++---- src/iocore/cache/CacheWrite.cc | 2 +- src/iocore/cache/P_CacheInternal.h | 22 +++++++++++++++++++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc index f0e830452b..4bf1e9e298 100644 --- a/src/iocore/cache/CacheDir.cc +++ b/src/iocore/cache/CacheDir.cc @@ -877,7 +877,7 @@ dir_lookaside_cleanup(Stripe *stripe) DDbg(dbg_ctl_dir_lookaside, "cleanup %X %X cleaned up", b->evac_frags.earliest_key.slice32(0), b->evac_frags.earliest_key.slice32(1)); i.remove(b); - free_CacheVC(b->earliest_evacuator); + free_CacheEvacuateDocVC(b->earliest_evacuator); free_EvacuationBlock(b, stripe->mutex->thread_holding); b = nb; goto Lagain; diff --git a/src/iocore/cache/CacheEvacuateDocVC.cc b/src/iocore/cache/CacheEvacuateDocVC.cc index 8aa7c7d244..f79aac4bb8 100644 --- a/src/iocore/cache/CacheEvacuateDocVC.cc +++ b/src/iocore/cache/CacheEvacuateDocVC.cc @@ -86,7 +86,7 @@ CacheEvacuateDocVC::evacuateDocDone(int /* event ATS_UNUSED */, Event * /* e ATS earliest_evac->total_len += doc->data_len(); if (earliest_evac->total_len == earliest_evac->doc_len) { dir_lookaside_fixup(&evac->earliest_key, this->stripe); - free_CacheVC(earliest_evac); + free_CacheEvacuateDocVC(earliest_evac); } } } @@ -137,7 +137,7 @@ CacheEvacuateDocVC::evacuateDocDone(int /* event ATS_UNUSED */, Event * /* e ATS break; } } - return free_CacheVC(this); + return free_CacheEvacuateDocVC(this); } int @@ -189,7 +189,7 @@ CacheEvacuateDocVC::evacuateReadHead(int /* event ATS_UNUSED */, Event * /* e AT // the whole document has been evacuated. Insert the directory // entry in the directory. dir_lookaside_fixup(&earliest_key, this->stripe); - return free_CacheVC(this); + return free_CacheEvacuateDocVC(this); } return EVENT_CONT; Lcollision: @@ -202,5 +202,5 @@ Lcollision: } Ldone: dir_lookaside_remove(&earliest_key, this->stripe); - return free_CacheVC(this); + return free_CacheEvacuateDocVC(this); } diff --git a/src/iocore/cache/CacheWrite.cc b/src/iocore/cache/CacheWrite.cc index 5b013b9df2..e1db30375b 100644 --- a/src/iocore/cache/CacheWrite.cc +++ b/src/iocore/cache/CacheWrite.cc @@ -584,7 +584,7 @@ Stripe::evacuateDocReadDone(int event, Event *e) } return evacuateWrite(doc_evacuator, event, e); Ldone: - free_CacheVC(doc_evacuator); + free_CacheEvacuateDocVC(doc_evacuator); doc_evacuator = nullptr; return aggWrite(event, e); } diff --git a/src/iocore/cache/P_CacheInternal.h b/src/iocore/cache/P_CacheInternal.h index 1a07f478aa..1ad1119988 100644 --- a/src/iocore/cache/P_CacheInternal.h +++ b/src/iocore/cache/P_CacheInternal.h @@ -142,8 +142,9 @@ struct CacheRemoveCont : public Continuation { }; // Global Data -extern ClassAllocator<CacheVC> cacheVConnectionAllocator; -extern CacheSync *cacheDirSync; +extern ClassAllocator<CacheVC> cacheVConnectionAllocator; +extern ClassAllocator<CacheEvacuateDocVC> cacheEvacuateDocVConnectionAllocator; +extern CacheSync *cacheDirSync; // Function Prototypes int cache_write(CacheVC *, CacheHTTPInfoVector *); int get_alternate_index(CacheHTTPInfoVector *cache_vector, CacheKey key); @@ -169,7 +170,7 @@ new_CacheVC(Continuation *cont) } inline int -free_CacheVC(CacheVC *cont) +free_CacheVCCommon(CacheVC *cont) { static DbgCtl dbg_ctl{"cache_free"}; Dbg(dbg_ctl, "free %p", cont); @@ -218,10 +219,25 @@ free_CacheVC(CacheVC *cont) #ifdef DEBUG SET_CONTINUATION_HANDLER(cont, &CacheVC::dead); #endif + return EVENT_DONE; +} + +inline int +free_CacheVC(CacheVC *cont) +{ + free_CacheVCCommon(cont); THREAD_FREE(cont, cacheVConnectionAllocator, this_thread()); return EVENT_DONE; } +inline int +free_CacheEvacuateDocVC(CacheEvacuateDocVC *cont) +{ + free_CacheVCCommon(cont); + THREAD_FREE(cont, cacheEvacuateDocVConnectionAllocator, this_thread()); + return EVENT_DONE; +} + inline int CacheVC::calluser(int event) {
