Merge pull request #104 from bibendovsky/fix/fastagi_start2
Clean up on socket initialization error
This commit is contained in:
commit
b3cd107043
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
@ -233,13 +234,29 @@ namespace AsterNET.FastAGI
|
|||
var ipAddress = IPAddress.Parse(address);
|
||||
serverSocket = new ServerSocket(port, ipAddress, SocketEncoding);
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if LOGGER
|
||||
if (ex is IOException)
|
||||
{
|
||||
logger.Error("Unable start AGI Server: cannot to bind to " + address + ":" + port + ".", ex);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (serverSocket != null)
|
||||
{
|
||||
serverSocket.Close();
|
||||
serverSocket = null;
|
||||
}
|
||||
|
||||
pool.Shutdown();
|
||||
#if LOGGER
|
||||
logger.Info("AGI Server shut down.");
|
||||
#endif
|
||||
|
||||
throw ex;
|
||||
}
|
||||
|
||||
#if LOGGER
|
||||
logger.Info("Listening on " + address + ":" + port + ".");
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue