* 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.

0.6.1-post-fixes
Teravus Ovares 2008-12-18 11:44:53 +00:00
parent 68c53c6da0
commit 0f25e8298b
2 changed files with 29 additions and 2 deletions

View File

@ -49,6 +49,8 @@ namespace OpenSim.Framework.Servers
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
private volatile int NotSocketErrors = 0;
private volatile bool HTTPDRunning = false;
protected Thread m_workerThread; protected Thread m_workerThread;
protected HttpListener m_httpListener; protected HttpListener m_httpListener;
@ -1362,7 +1364,7 @@ namespace OpenSim.Framework.Servers
{ {
m_log.Info("[HTTPD]: Spawned main thread OK"); m_log.Info("[HTTPD]: Spawned main thread OK");
//m_httpListener = new HttpListener(); //m_httpListener = new HttpListener();
NotSocketErrors = 0;
if (!m_ssl) if (!m_ssl)
{ {
//m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); //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 = new HttpServer.HttpListener(IPAddress.Any, (int)m_port);
m_httpListener2.ExceptionThrown += httpServerException; m_httpListener2.ExceptionThrown += httpServerException;
m_httpListener2.LogWriter = httpserverlog; m_httpListener2.LogWriter = httpserverlog;
m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor;
} }
else else
@ -1381,6 +1384,7 @@ namespace OpenSim.Framework.Servers
m_httpListener2.RequestHandler += OnHandleRequestIOThread; m_httpListener2.RequestHandler += OnHandleRequestIOThread;
//m_httpListener.Start(); //m_httpListener.Start();
m_httpListener2.Start(64); m_httpListener2.Start(64);
HTTPDRunning = true;
//HttpListenerContext context; //HttpListenerContext context;
//while (true) //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) public void httpServerException(object source, Exception exception)
{ {
m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
@ -1403,6 +1423,13 @@ namespace OpenSim.Framework.Servers
public void Stop() public void Stop()
{ {
HTTPDRunning = false;
m_httpListener2.ExceptionThrown -= httpServerException;
m_httpListener2.DisconnectHandler = null;
m_httpListener2.LogWriter = null;
m_httpListener2.RequestHandler -= OnHandleRequestIOThread;
m_httpListener2.Stop(); m_httpListener2.Stop();
} }

Binary file not shown.