aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs28
-rw-r--r--OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs17
-rw-r--r--OpenSim/Framework/Util.cs9
4 files changed, 45 insertions, 11 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 85b19c0..b24336d 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1025,7 +1025,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1025 return buffer; 1025 return buffer;
1026 } 1026 }
1027 1027
1028 // JsonRpc (v2.0 only) 1028 // JsonRpc (v2.0 only)
1029 // Batch requests not yet supported
1029 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response) 1030 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response)
1030 { 1031 {
1031 Stream requestStream = request.InputStream; 1032 Stream requestStream = request.InputStream;
@@ -1065,8 +1066,26 @@ namespace OpenSim.Framework.Servers.HttpServer
1065 { 1066 {
1066 jsonRpcHandlers.TryGetValue(methodname, out method); 1067 jsonRpcHandlers.TryGetValue(methodname, out method);
1067 } 1068 }
1068 1069 bool res = false;
1069 method(jsonRpcRequest, ref jsonRpcResponse); 1070 try
1071 {
1072 res = method(jsonRpcRequest, ref jsonRpcResponse);
1073 if(!res)
1074 {
1075 // The handler sent back an unspecified error
1076 if(jsonRpcResponse.Error.Code == 0)
1077 {
1078 jsonRpcResponse.Error.Code = ErrorCode.InternalError;
1079 }
1080 }
1081 }
1082 catch (Exception e)
1083 {
1084 string ErrorMessage = string.Format("[BASE HTTP SERVER]: Json-Rpc Handler Error method {0} - {1}", methodname, e.Message);
1085 m_log.Error(ErrorMessage);
1086 jsonRpcResponse.Error.Code = ErrorCode.InternalError;
1087 jsonRpcResponse.Error.Message = ErrorMessage;
1088 }
1070 } 1089 }
1071 else // Error no hanlder defined for requested method 1090 else // Error no hanlder defined for requested method
1072 { 1091 {
@@ -1731,6 +1750,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1731 1750
1732 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1751 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1733 m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); 1752 m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000);
1753 m_PollServiceManager.Start();
1734 HTTPDRunning = true; 1754 HTTPDRunning = true;
1735 1755
1736 //HttpListenerContext context; 1756 //HttpListenerContext context;
@@ -1781,6 +1801,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1781 HTTPDRunning = false; 1801 HTTPDRunning = false;
1782 try 1802 try
1783 { 1803 {
1804 m_PollServiceManager.Stop();
1805
1784 m_httpListener2.ExceptionThrown -= httpServerException; 1806 m_httpListener2.ExceptionThrown -= httpServerException;
1785 //m_httpListener2.DisconnectHandler = null; 1807 //m_httpListener2.DisconnectHandler = null;
1786 1808
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs b/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs
index 7334049..5bab508 100644
--- a/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs
+++ b/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs
@@ -30,5 +30,5 @@ using OpenMetaverse.StructuredData;
30 30
31namespace OpenSim.Framework.Servers.HttpServer 31namespace OpenSim.Framework.Servers.HttpServer
32{ 32{
33 public delegate void JsonRPCMethod(OSDMap jsonRpcRequest, ref JsonRpcResponse response); 33 public delegate bool JsonRPCMethod(OSDMap jsonRpcRequest, ref JsonRpcResponse response);
34} 34}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 8d50151..3e84c55 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -45,19 +45,26 @@ namespace OpenSim.Framework.Servers.HttpServer
45 private uint m_WorkerThreadCount = 0; 45 private uint m_WorkerThreadCount = 0;
46 private Thread[] m_workerThreads; 46 private Thread[] m_workerThreads;
47 private PollServiceWorkerThread[] m_PollServiceWorkerThreads; 47 private PollServiceWorkerThread[] m_PollServiceWorkerThreads;
48 private bool m_running = true; 48 private volatile bool m_running = true;
49 private int m_pollTimeout;
49 50
50 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) 51 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
51 { 52 {
52 m_server = pSrv; 53 m_server = pSrv;
53 m_WorkerThreadCount = pWorkerThreadCount; 54 m_WorkerThreadCount = pWorkerThreadCount;
55 m_pollTimeout = pTimeout;
56 }
57
58 public void Start()
59 {
60 m_running = true;
54 m_workerThreads = new Thread[m_WorkerThreadCount]; 61 m_workerThreads = new Thread[m_WorkerThreadCount];
55 m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; 62 m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];
56 63
57 //startup worker threads 64 //startup worker threads
58 for (uint i = 0; i < m_WorkerThreadCount; i++) 65 for (uint i = 0; i < m_WorkerThreadCount; i++)
59 { 66 {
60 m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); 67 m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, m_pollTimeout);
61 m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; 68 m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent;
62 69
63 m_workerThreads[i] 70 m_workerThreads[i]
@@ -136,8 +143,10 @@ namespace OpenSim.Framework.Servers.HttpServer
136 143
137 } 144 }
138 145
139 ~PollServiceRequestManager() 146 public void Stop()
140 { 147 {
148 m_running = false;
149
141 foreach (object o in m_requests) 150 foreach (object o in m_requests)
142 { 151 {
143 PollServiceHttpRequest req = (PollServiceHttpRequest) o; 152 PollServiceHttpRequest req = (PollServiceHttpRequest) o;
@@ -151,8 +160,6 @@ namespace OpenSim.Framework.Servers.HttpServer
151 { 160 {
152 t.Abort(); 161 t.Abort();
153 } 162 }
154
155 m_running = false;
156 } 163 }
157 } 164 }
158} \ No newline at end of file 165} \ No newline at end of file
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index f6c9d15..9b1e97d 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1658,8 +1658,13 @@ namespace OpenSim.Framework
1658 if (m_ThreadPool != null) 1658 if (m_ThreadPool != null)
1659 throw new InvalidOperationException("SmartThreadPool is already initialized"); 1659 throw new InvalidOperationException("SmartThreadPool is already initialized");
1660 1660
1661 m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); 1661 STPStartInfo startInfo = new STPStartInfo();
1662 m_ThreadPool.Name = "Util"; 1662 startInfo.ThreadPoolName = "Util";
1663 startInfo.IdleTimeout = 2000;
1664 startInfo.MaxWorkerThreads = maxThreads;
1665 startInfo.MinWorkerThreads = 2;
1666
1667 m_ThreadPool = new SmartThreadPool(startInfo);
1663 } 1668 }
1664 1669
1665 public static int FireAndForgetCount() 1670 public static int FireAndForgetCount()