Comment 0 for bug 1415254

Revision history for this message
Jason Stephenson (jstephenson) wrote :

CStoreEditor (used throughout the backend and some utility scripts) should track the number of times its connect and disconnect methods are called and only actually disconnect when the count reaches 0. This improvement would reduce the amount of discipline required in using CStoreEditor. It would also reduce the possibility of a subroutine disconnecting a CStoreEditor that needs to remain connected after the subroutine finishes.

The proposal is to add a connection_count state variable to CStoreEditor. It will be initialized to 0 in the constructor.

Every call to connect will increment the count by 1. (Connect already checks if the editor is connected and only connects if it isn't already.

The disconnect method will decrement the connection count by 1, if the count is greate than 0, each time it is called. If the count reaches 0, then the actual disconnect will happen if the editor is connected.

The reset method, which is mainly called from the CStoreEditor's destructor, will set the connection count to 0 before calling disconnect. This will force the disconnect to happen as is the current behavior of the reset method.