From 0f25e8298b211667aaf73241ca272fe591fc249e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 18 Dec 2008 11:44:53 +0000 Subject: * Add a nasty hack to try and give the HttpServer a few extra lives until we dig more into what's causing it to stop listening. --- OpenSim/Framework/Servers/BaseHttpServer.cs | 31 ++++++++++++++++++++++++++-- bin/HttpServer.dll | Bin 139264 -> 139264 bytes 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 40eaba5..91ad3a3 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -48,7 +48,9 @@ namespace OpenSim.Framework.Servers { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); - + + private volatile int NotSocketErrors = 0; + private volatile bool HTTPDRunning = false; protected Thread m_workerThread; protected HttpListener m_httpListener; @@ -1362,7 +1364,7 @@ namespace OpenSim.Framework.Servers { m_log.Info("[HTTPD]: Spawned main thread OK"); //m_httpListener = new HttpListener(); - + NotSocketErrors = 0; if (!m_ssl) { //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); @@ -1370,6 +1372,7 @@ namespace OpenSim.Framework.Servers m_httpListener2 = new HttpServer.HttpListener(IPAddress.Any, (int)m_port); m_httpListener2.ExceptionThrown += httpServerException; m_httpListener2.LogWriter = httpserverlog; + m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor; } else @@ -1381,6 +1384,7 @@ namespace OpenSim.Framework.Servers m_httpListener2.RequestHandler += OnHandleRequestIOThread; //m_httpListener.Start(); m_httpListener2.Start(64); + HTTPDRunning = true; //HttpListenerContext context; //while (true) @@ -1396,6 +1400,22 @@ namespace OpenSim.Framework.Servers } } + public void httpServerDisconnectMonitor(HttpServer.IHttpClientContext source, SocketError err) + { + switch (err) + { + case SocketError.NotSocket: + NotSocketErrors++; + if (HTTPDRunning)// && NotSocketErrors > 5) + { + Stop(); + StartHTTP(); + m_log.Warn("[HTTPSERVER]: Died. Trying to kick....."); + } + break; + } + } + public void httpServerException(object source, Exception exception) { m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); @@ -1403,6 +1423,13 @@ namespace OpenSim.Framework.Servers public void Stop() { + HTTPDRunning = false; + m_httpListener2.ExceptionThrown -= httpServerException; + m_httpListener2.DisconnectHandler = null; + + m_httpListener2.LogWriter = null; + m_httpListener2.RequestHandler -= OnHandleRequestIOThread; + m_httpListener2.Stop(); } diff --git a/bin/HttpServer.dll b/bin/HttpServer.dll index f940d13..c57e023 100644 Binary files a/bin/HttpServer.dll and b/bin/HttpServer.dll differ -- cgit v1.1