aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs31
1 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
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 50 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
51 51
52 private volatile int NotSocketErrors = 0;
53 private volatile bool HTTPDRunning = false;
52 54
53 protected Thread m_workerThread; 55 protected Thread m_workerThread;
54 protected HttpListener m_httpListener; 56 protected HttpListener m_httpListener;
@@ -1362,7 +1364,7 @@ namespace OpenSim.Framework.Servers
1362 { 1364 {
1363 m_log.Info("[HTTPD]: Spawned main thread OK"); 1365 m_log.Info("[HTTPD]: Spawned main thread OK");
1364 //m_httpListener = new HttpListener(); 1366 //m_httpListener = new HttpListener();
1365 1367 NotSocketErrors = 0;
1366 if (!m_ssl) 1368 if (!m_ssl)
1367 { 1369 {
1368 //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); 1370 //m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
@@ -1370,6 +1372,7 @@ namespace OpenSim.Framework.Servers
1370 m_httpListener2 = new HttpServer.HttpListener(IPAddress.Any, (int)m_port); 1372 m_httpListener2 = new HttpServer.HttpListener(IPAddress.Any, (int)m_port);
1371 m_httpListener2.ExceptionThrown += httpServerException; 1373 m_httpListener2.ExceptionThrown += httpServerException;
1372 m_httpListener2.LogWriter = httpserverlog; 1374 m_httpListener2.LogWriter = httpserverlog;
1375 m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor;
1373 1376
1374 } 1377 }
1375 else 1378 else
@@ -1381,6 +1384,7 @@ namespace OpenSim.Framework.Servers
1381 m_httpListener2.RequestHandler += OnHandleRequestIOThread; 1384 m_httpListener2.RequestHandler += OnHandleRequestIOThread;
1382 //m_httpListener.Start(); 1385 //m_httpListener.Start();
1383 m_httpListener2.Start(64); 1386 m_httpListener2.Start(64);
1387 HTTPDRunning = true;
1384 1388
1385 //HttpListenerContext context; 1389 //HttpListenerContext context;
1386 //while (true) 1390 //while (true)
@@ -1396,6 +1400,22 @@ namespace OpenSim.Framework.Servers
1396 } 1400 }
1397 } 1401 }
1398 1402
1403 public void httpServerDisconnectMonitor(HttpServer.IHttpClientContext source, SocketError err)
1404 {
1405 switch (err)
1406 {
1407 case SocketError.NotSocket:
1408 NotSocketErrors++;
1409 if (HTTPDRunning)// && NotSocketErrors > 5)
1410 {
1411 Stop();
1412 StartHTTP();
1413 m_log.Warn("[HTTPSERVER]: Died. Trying to kick.....");
1414 }
1415 break;
1416 }
1417 }
1418
1399 public void httpServerException(object source, Exception exception) 1419 public void httpServerException(object source, Exception exception)
1400 { 1420 {
1401 m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); 1421 m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
@@ -1403,6 +1423,13 @@ namespace OpenSim.Framework.Servers
1403 1423
1404 public void Stop() 1424 public void Stop()
1405 { 1425 {
1426 HTTPDRunning = false;
1427 m_httpListener2.ExceptionThrown -= httpServerException;
1428 m_httpListener2.DisconnectHandler = null;
1429
1430 m_httpListener2.LogWriter = null;
1431 m_httpListener2.RequestHandler -= OnHandleRequestIOThread;
1432
1406 m_httpListener2.Stop(); 1433 m_httpListener2.Stop();
1407 } 1434 }
1408 1435