From 6ad750d92d0999e02aa0463350405f56101960f1 Mon Sep 17 00:00:00 2001 From: Netaji Panigrahi <114923459+NetajiPanigrahi@users.noreply.github.com> Date: Wed, 11 Oct 2023 21:03:22 +0530 Subject: [PATCH] CMXB7-5636:Onewifi crash observed with function rbusAsyncSubscribeRetrier_CompareSubscription (#167) * CMXB7-5636:Onewifi crash observed with function rbusAsyncSubscribeRetrier_CompareSubscription Reason for change: AsyncSubscriptions list maintained in the consumer is not mutex protected while remove from the List. Signed-off-by: Netaji Panigrahi Netaji_Panigrahi@comcast.com --- src/rbus/rbus_asyncsubscribe.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/rbus/rbus_asyncsubscribe.c b/src/rbus/rbus_asyncsubscribe.c index c228f453..6023370d 100644 --- a/src/rbus/rbus_asyncsubscribe.c +++ b/src/rbus/rbus_asyncsubscribe.c @@ -94,7 +94,7 @@ static int rbusAsyncSubscribeRetrier_CompareSubscription(const void *pitem, cons if((!item)||(!sub)) return 1; - if( item->subscription->handle == sub->handle && + if (item->subscription && (item->subscription->handle == sub->handle) && strcmp(item->subscription->eventName, sub->eventName) == 0 && rbusFilter_Compare(item->subscription->filter, sub->filter) == 0) return 0; @@ -168,7 +168,7 @@ static void rbusAsyncSubscribeRetrier_SendSubscriptionRequests() while(li) { - AsyncSubscription_t* item; + AsyncSubscription_t* item = NULL; rtListItem_GetData(li, (void**)&item); @@ -249,17 +249,15 @@ static void rbusAsyncSubscribeRetrier_SendSubscriptionRequests() } _subscribe_async_callback_handler(item->subscription->handle, item->subscription, responseErr); - - item->subscription = NULL;/*ownership no longer ours*/ - //store the next item, because we are removing this li item from list + LOCK(); + item->subscription = NULL; rtListItem_GetNext(li, &tmp); - rtList_RemoveItem(gRetrier->items, li, rbusAsyncSubscribeRetrier_FreeSubscription); - + UNLOCK(); li = tmp; continue;//li is already the next item so avoid GetNext below - } + } } rtListItem_GetNext(li, &li); }