From 6703954a4486cb3bc909cf2076627832d33e860c Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Fri, 22 Apr 2016 01:58:10 -0400 Subject: [PATCH] catch some errors --- hbc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hbc b/hbc index d70dc0e..4a16dbc 100755 --- a/hbc +++ b/hbc @@ -26,10 +26,12 @@ except: require on Linux python-filelock python-daemon vs 1.61 or > + run sudo easy_install-2.7 lockfile python-daemon on *bsd py27-lockfile py27-daemon - or run sudo easy_install-2.7 lockfile python-daemon""" + run sudo pkg install -y py27-lockfile py27-daemon +""" sys.exit(1) import syslog @@ -43,6 +45,7 @@ MAXRECV = 32767 running = True dorestart = False +warned1 = False class NullDevice: def write(self, s): @@ -66,6 +69,8 @@ class Conn: self.sock.getsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR) | 1) def sendto(self, msg, ID = 'HTB'): # default ID is HearTBeat + global warned1 + msg['name'] = iam msg['id'] = self.conId msg['ver'] = VER @@ -73,7 +78,12 @@ class Conn: m = dicttos(ID, msg) mz = zlib.compress(m,9) if verbose: print "conn.send('%s', (%s:%s) %s>%s)" % (msg, self.addr, self.port, len(m), len(mz)) - self.sock.sendto(m, (self.addr, self.port)) + try: + self.sock.sendto(m, (self.addr, self.port)) + except socket.error as e: + if not warned1: print "socket error: %s %s:%s" % (e, self.addr, self.port) + warned1 = True + return self.send += 1 self.lastsend = time.time() @@ -468,7 +478,7 @@ if fdaemon: working_directory='/tmp', umask=0o002, pidfile=pidfile, - initgroups=False, +# initgroups=False, ) context.signal_map = {