Commit 36e1175b authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos
Browse files

Clean up resources upon exit

Wrap the main loop in a try..finally statement, calling our cleanup handler to
free all obtained resources.
Signed-off-by: default avatarApollon Oikonomopoulos <>
parent 68da8f20
......@@ -335,6 +335,24 @@ class VMNetProxy(object): # pylint: disable=R0902
self._setup_nfqueue(ns_queue_num, AF_INET6, self.ns_response)
self.ipv6_enabled = True
def _cleanup(self):
""" Free all resources for a graceful exit
""""Cleaning up")
logging.debug("Closing netfilter queues")
for q in self.nfq.values():
logging.debug("Closing socket")
logging.debug("Stopping inotify watches")
self.notifier.stop()"Cleanup finished")
def _setup_nfqueue(self, queue_num, family, callback):
logging.debug("Setting up NFQUEUE for queue %d, AF %s",
queue_num, family)
......@@ -659,6 +677,15 @@ class VMNetProxy(object): # pylint: disable=R0902
logging.debug("Sent %d RAs in %.2f seconds", i, time.time() - start)
def serve(self):
""" Safely perform the main loop, freeing all resources upon exit
def _serve(self):
""" Loop forever, serving DHCP requests
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment