Skip to content

Commit

Permalink
Potential fix for the too many open files error
Browse files Browse the repository at this point in the history
  • Loading branch information
brian7704 committed Aug 23, 2024
1 parent c4d00b1 commit f4083ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions opentakserver/controllers/client_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def __init__(self, address, port, sock, logger, app, is_ssl):
self.logger.debug("Got common name {}".format(self.common_name))
except BaseException as e:
logger.warning("Failed to do handshake: {}".format(e))
self.send_disconnect_cot()
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
self.shutdown = True
self.logger.error(traceback.format_exc())

# RabbitMQ
try:
Expand Down Expand Up @@ -91,15 +96,13 @@ def on_message(self, unused_channel, basic_deliver, properties, body):
body = json.loads(body)
if body['uid'] != self.uid:
self.sock.send(body['cot'].encode())
except BrokenPipeError:
self.logger.error("{}: Broken Pipe, closing socket".format(self.callsign))
except BaseException as e:
self.logger.error(f"{self.callsign}: {e}, closing socket")
self.send_disconnect_cot()
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
self.shutdown = True
self.logger.error(traceback.format_exc())
except:
self.logger.error(traceback.format_exc())

def run(self):
while not self.shutdown:
Expand Down

0 comments on commit f4083ae

Please sign in to comment.