cosmetics

master
UbitUmarov 2020-07-13 06:16:11 +01:00
parent 6ba5b78851
commit fe7d9625aa
2 changed files with 15 additions and 20 deletions

View File

@ -121,8 +121,7 @@ namespace OSHttpServer
SocketError disconnectError = SocketError.HostDown; SocketError disconnectError = SocketError.HostDown;
for (int i = 0; i < m_contexts.Count; i++) for (int i = 0; i < m_contexts.Count; i++)
{ {
HttpClientContext context = null; if (m_contexts.TryDequeue(out HttpClientContext context))
if (m_contexts.TryDequeue(out context))
{ {
try try
{ {

View File

@ -91,11 +91,6 @@ namespace OSHttpServer
public bool StopMonitoring; public bool StopMonitoring;
/// <summary>
/// Context have been started (a new client have connected)
/// </summary>
public event EventHandler Started;
public IPEndPoint LocalIPEndPoint {get; set;} public IPEndPoint LocalIPEndPoint {get; set;}
/// <summary> /// <summary>
@ -213,8 +208,8 @@ namespace OSHttpServer
/// </remarks> /// </remarks>
public virtual void Start() public virtual void Start()
{ {
ReceiveLoop(); Task tk = new Task(() => ReceiveLoop());
Started?.Invoke(this, EventArgs.Empty); tk.Start();
} }
/// <summary> /// <summary>
@ -488,7 +483,6 @@ namespace OSHttpServer
m_waitingResponse = true; m_waitingResponse = true;
} }
// for now pipeline requests need to be serialized by opensim
if(donow) if(donow)
RequestReceived?.Invoke(this, new RequestEventArgs(m_currentRequest)); RequestReceived?.Invoke(this, new RequestEventArgs(m_currentRequest));
@ -530,6 +524,11 @@ namespace OSHttpServer
isSendingResponse = false; isSendingResponse = false;
m_currentResponse?.Clear(); m_currentResponse?.Clear();
m_currentResponse = null; m_currentResponse = null;
lock (m_requestsLock)
m_waitingResponse = false;
if(contextID < 0)
return;
bool doclose = ctype == ConnectionType.Close; bool doclose = ctype == ConnectionType.Close;
if (doclose) if (doclose)
@ -559,21 +558,18 @@ namespace OSHttpServer
return; return;
TriggerKeepalive = true; TriggerKeepalive = true;
HttpRequest nextRequest = null;
lock (m_requestsLock) lock (m_requestsLock)
{ {
m_waitingResponse = false;
if (m_requests != null && m_requests.Count > 0) if (m_requests != null && m_requests.Count > 0)
{ nextRequest = m_requests.Dequeue();
HttpRequest nextRequest = m_requests.Dequeue(); if (nextRequest != null && RequestReceived != null)
if (nextRequest != null)
{
m_waitingResponse = true; m_waitingResponse = true;
}
if (nextRequest != null)
RequestReceived?.Invoke(this, new RequestEventArgs(nextRequest)); RequestReceived?.Invoke(this, new RequestEventArgs(nextRequest));
} }
} }
}
}
}
/// <summary> /// <summary>
/// Send a response. /// Send a response.