mirror of
https://github.com/FrodoVDR/UdpPipe.git
synced 2023-10-10 13:36:54 +02:00
Added some enhancements to the head part to make reconnects work better.
This commit is contained in:
parent
5c6b42de01
commit
f6765cfed1
@ -219,7 +219,7 @@ class Head(PipeBase):
|
|||||||
lastReport=datetime.datetime.now()
|
lastReport=datetime.datetime.now()
|
||||||
while not(self._terminate) and tailConnection:
|
while not(self._terminate) and tailConnection:
|
||||||
try:
|
try:
|
||||||
ready=select.select(socketArray, [], [], 3600)
|
ready=select.select(socketArray, [], [], 180)
|
||||||
except select.error, (_errno, _strerror):
|
except select.error, (_errno, _strerror):
|
||||||
if _errno == errno.EINTR:
|
if _errno == errno.EINTR:
|
||||||
continue
|
continue
|
||||||
@ -287,6 +287,7 @@ class Head(PipeBase):
|
|||||||
if not(found):
|
if not(found):
|
||||||
lstCfg[2].close()
|
lstCfg[2].close()
|
||||||
self.listenerConfig.remove(lstCfg)
|
self.listenerConfig.remove(lstCfg)
|
||||||
|
socketArray.remove(lstCfg[2])
|
||||||
self.log.info("[Head] Deleted UDP Listener <%s> on port <%d>" % (lstCfg[0], lstCfg[1]))
|
self.log.info("[Head] Deleted UDP Listener <%s> on port <%d>" % (lstCfg[0], lstCfg[1]))
|
||||||
continue
|
continue
|
||||||
# find the outbound socket
|
# find the outbound socket
|
||||||
@ -303,6 +304,7 @@ class Head(PipeBase):
|
|||||||
break
|
break
|
||||||
if not(found):
|
if not(found):
|
||||||
self.log.warn("[Head] Received a response for an unknown client on port %d" % (fields['srvPort']))
|
self.log.warn("[Head] Received a response for an unknown client on port %d" % (fields['srvPort']))
|
||||||
|
continue
|
||||||
|
|
||||||
for lstCfg in self.listenerConfig:
|
for lstCfg in self.listenerConfig:
|
||||||
if r==lstCfg[2]:
|
if r==lstCfg[2]:
|
||||||
@ -333,6 +335,10 @@ class Head(PipeBase):
|
|||||||
dataBuffer.close()
|
dataBuffer.close()
|
||||||
ctlBuffer.close()
|
ctlBuffer.close()
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
self.log.warn("[Head] No activity for 180 seconds, assumung Tail is absent")
|
||||||
|
socketArray.remove(clientSocket)
|
||||||
|
tailConnection=False
|
||||||
now=datetime.datetime.now()
|
now=datetime.datetime.now()
|
||||||
if (now-lastReport).seconds>=(3600*24):
|
if (now-lastReport).seconds>=(3600*24):
|
||||||
self.logStats(0, None)
|
self.logStats(0, None)
|
||||||
@ -343,10 +349,13 @@ class Head(PipeBase):
|
|||||||
elif e.errno == errno.ECONNRESET:
|
elif e.errno == errno.ECONNRESET:
|
||||||
self.log.warn("[Head] Tail disconnected")
|
self.log.warn("[Head] Tail disconnected")
|
||||||
socketArray.remove(clientSocket)
|
socketArray.remove(clientSocket)
|
||||||
|
tailConnection=False
|
||||||
else:
|
else:
|
||||||
|
self.log.exception(e)
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.exception(e)
|
self.log.exception(e)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class Tail(PipeBase):
|
class Tail(PipeBase):
|
||||||
|
Loading…
Reference in New Issue
Block a user