From 9e31d6d4795acd561271409babd6d7852377fe6a Mon Sep 17 00:00:00 2001 From: Evan Zelkowitz Date: Wed, 8 Dec 2021 15:13:25 -0700 Subject: [PATCH] Changed to using std::atomic ptr for hosting and do ptr swap --- iocore/cache/P_CacheHosting.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iocore/cache/P_CacheHosting.h b/iocore/cache/P_CacheHosting.h index ba6fecd812d..0948601d0ed 100644 --- a/iocore/cache/P_CacheHosting.h +++ b/iocore/cache/P_CacheHosting.h @@ -152,7 +152,7 @@ class CacheHostTable struct CacheHostTableConfig; typedef int (CacheHostTableConfig::*CacheHostTabHandler)(int, void *); struct CacheHostTableConfig : public Continuation { - CacheHostTable **ppt; + std::atomic ppt; CacheHostTableConfig(CacheHostTable **appt) : Continuation(nullptr), ppt(appt) { SET_HANDLER((CacheHostTabHandler)&CacheHostTableConfig::mainEvent); @@ -163,8 +163,9 @@ struct CacheHostTableConfig : public Continuation { { (void)e; (void)event; - CacheHostTable *t = new CacheHostTable((*ppt)->cache, (*ppt)->type); - CacheHostTable *old = (CacheHostTable *)ink_atomic_swap(&t, *ppt); + CacheHostTable *t = new CacheHostTable((*ppt)->cache, (*ppt)->type); + auto old = *ppt; + (*ppt) = t; new_Deleter(old, CACHE_MEM_FREE_TIMEOUT); return EVENT_DONE; }