Skip to content

Commit

Permalink
CMXB7-5636:Onewifi crash observed with function rbusAsyncSubscribeRet…
Browse files Browse the repository at this point in the history
…rier_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 [email protected]
  • Loading branch information
NetajiPanigrahi authored Oct 11, 2023
1 parent c192ed6 commit 6ad750d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/rbus/rbus_asyncsubscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +168,7 @@ static void rbusAsyncSubscribeRetrier_SendSubscriptionRequests()

while(li)
{
AsyncSubscription_t* item;
AsyncSubscription_t* item = NULL;

rtListItem_GetData(li, (void**)&item);

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6ad750d

Please sign in to comment.