- Trying to connect to server every 20 seconds forever is extremely rude to its owner. Let's be polite and do exponential back-off. (See #2411)
- [PyOpenSSL] Ported [7443] to pyopenssl branch.
This commit is contained in:
parent
4a58bc4797
commit
7c0696093a
|
@ -123,6 +123,8 @@ class NBCommonClient(CommonClient):
|
||||||
self.on_connect_failure(retry)
|
self.on_connect_failure(retry)
|
||||||
|
|
||||||
def _on_connected(self):
|
def _on_connected(self):
|
||||||
|
# connect succeeded, so no need of this callback anymore
|
||||||
|
self.on_connect_failure = None
|
||||||
self.connected = 'tcp'
|
self.connected = 'tcp'
|
||||||
if self._Ssl:
|
if self._Ssl:
|
||||||
transports_nb.NonBlockingTLS().PlugIn(self, now=1)
|
transports_nb.NonBlockingTLS().PlugIn(self, now=1)
|
||||||
|
|
|
@ -342,11 +342,11 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
def pollin(self):
|
def pollin(self):
|
||||||
self._do_receive()
|
self._do_receive()
|
||||||
|
|
||||||
def pollend(self):
|
def pollend(self, retry=False):
|
||||||
conn_failure_cb = self.on_connect_failure
|
conn_failure_cb = self.on_connect_failure
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
if conn_failure_cb:
|
if conn_failure_cb:
|
||||||
conn_failure_cb()
|
conn_failure_cb(retry)
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
if self.state == -2: # already disconnected
|
if self.state == -2: # already disconnected
|
||||||
|
@ -442,8 +442,8 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
if errnum in (ERR_DISCONN, errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN):
|
if errnum in (ERR_DISCONN, errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN):
|
||||||
self.DEBUG(errtxt, 'error')
|
self.DEBUG(errtxt, 'error')
|
||||||
log.error("Got Disconnected: " + errtxt)
|
log.error("Got Disconnected: " + errtxt)
|
||||||
self.pollend()
|
self.pollend(retry=(errnum in (ERR_DISCONN, errno.ECONNRESET)))
|
||||||
# don't proccess result, cas it will raise error
|
# don't process result, because it will raise an error
|
||||||
return
|
return
|
||||||
|
|
||||||
if received is None:
|
if received is None:
|
||||||
|
@ -451,7 +451,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
self.DEBUG(errtxt, 'error')
|
self.DEBUG(errtxt, 'error')
|
||||||
log.error("Error: " + errtxt)
|
log.error("Error: " + errtxt)
|
||||||
if self.state >= 0:
|
if self.state >= 0:
|
||||||
self.pollend()
|
self.pollend(retry=True)
|
||||||
return
|
return
|
||||||
received = ''
|
received = ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue