From 624d1d215c138dd91f9bea7d3d4f0a1b33dba3c2 Mon Sep 17 00:00:00 2001 From: Boris Bendovsky Date: Tue, 25 Apr 2017 09:02:06 +0300 Subject: [PATCH] Clean up on socket initialization error --- .../Asterisk.NET/FastAGI/AsteriskFastAGI.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs index 8e7decf..25c128d 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs @@ -240,6 +240,20 @@ namespace AsterNET.FastAGI #endif throw ex; } + finally + { + if (serverSocket != null) + { + serverSocket.Close(); + serverSocket = null; + } + + pool.Shutdown(); +#if LOGGER + logger.Info("AGIServer shut down."); +#endif + } + #if LOGGER logger.Info("Listening on " + address + ":" + port + "."); #endif