LiveQuerier could be leaked as liveQuerierStopped() delegate might not be called

Description

Based on the recent fix for https://couchbasecloud.atlassian.net/browse/CBL-2673#icft=CBL-2673 that adds liveQuerierStopped() to LiveQuerierDelegate for notifying when the LiveQuerier is completely stopped so that its consumer (C4Query) knows when it can break up the retained cycle b/w itself and the delegate object and cleanup the memory. 

However there is a bug in LiveQuerier::_stop() that _delegate.liveQuerierStopped() might not be called if the _query object is not initialized in the _runQuery() yet when the _stop() is called. This issue has been found when running "Close Database with Active Live Query" test in CBL-C; the test was failed as the the c4Query and LiveQuerier object were leaked after the test was done.

After discussing with , the fix would be that 
1. _delegate.liveQuerierStopped() will be called whether the _query is initialized or not.
2. Adding _stopping check to the stop() method to make sure that the stop operation will be called only once.

Activity

Show:
Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created December 21, 2021 at 10:49 PM
Updated August 31, 2024 at 10:56 AM
Resolved December 22, 2021 at 7:33 PM
Instabug