mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-22 10:20:59 +00:00
Better cleanup.
This commit is contained in:
parent
f3fc426830
commit
2a5e8e5971
@ -970,6 +970,7 @@ class HTTPNativeStorageServer(service.MultiService):
|
|||||||
self._connection_status = connection_status.ConnectionStatus.unstarted()
|
self._connection_status = connection_status.ConnectionStatus.unstarted()
|
||||||
self._version = None
|
self._version = None
|
||||||
self._last_connect_time = None
|
self._last_connect_time = None
|
||||||
|
self._connecting_deferred = None
|
||||||
|
|
||||||
def get_permutation_seed(self):
|
def get_permutation_seed(self):
|
||||||
return self._permutation_seed
|
return self._permutation_seed
|
||||||
@ -1060,20 +1061,30 @@ class HTTPNativeStorageServer(service.MultiService):
|
|||||||
|
|
||||||
def stop_connecting(self):
|
def stop_connecting(self):
|
||||||
self._lc.stop()
|
self._lc.stop()
|
||||||
|
if self._connecting_deferred is not None:
|
||||||
|
self._connecting_deferred.cancel()
|
||||||
|
|
||||||
def try_to_connect(self):
|
def try_to_connect(self):
|
||||||
self._connect()
|
self._connect()
|
||||||
|
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
result = self._istorage_server.get_version()
|
result = self._istorage_server.get_version()
|
||||||
|
|
||||||
|
def remove_connecting_deferred(result):
|
||||||
|
self._connecting_deferred = None
|
||||||
|
return result
|
||||||
|
|
||||||
# Set a short timeout since we're relying on this for server liveness.
|
# Set a short timeout since we're relying on this for server liveness.
|
||||||
result.addTimeout(5, self._reactor)
|
self._connecting_deferred = result.addTimeout(5, self._reactor).addBoth(
|
||||||
result.addCallbacks(
|
remove_connecting_deferred).addCallbacks(
|
||||||
self._got_version,
|
self._got_version,
|
||||||
self._failed_to_connect
|
self._failed_to_connect
|
||||||
)
|
)
|
||||||
|
|
||||||
def stopService(self):
|
def stopService(self):
|
||||||
|
if self._connecting_deferred is not None:
|
||||||
|
self._connecting_deferred.cancel()
|
||||||
|
|
||||||
result = service.MultiService.stopService(self)
|
result = service.MultiService.stopService(self)
|
||||||
if self._lc.running:
|
if self._lc.running:
|
||||||
self._lc.stop()
|
self._lc.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user