oshttp send: modern TAP is still just a complex wrapper of 'obsolete' APM hidding at IL level, so just use the 'obsolete'

This commit is contained in:
UbitUmarov
2021-09-04 13:55:56 +01:00
parent 1e1ec44707
commit 52753972ee
4 changed files with 127 additions and 129 deletions

View File

@@ -4,7 +4,6 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using OSHttpServer.Exceptions;
using OSHttpServer.Parser;
using System.Net.Security;
@@ -531,11 +530,11 @@ namespace OSHttpServer
return true;
}
public void ContinueSendResponse(bool notThrottled)
public void ContinueSendResponse()
{
if(m_currentResponse == null)
return;
ContextTimeoutManager.EnqueueSend(this, m_currentResponse.Priority, notThrottled);
ContextTimeoutManager.EnqueueSend(this, m_currentResponse.Priority, true);
}
public void EndSendResponse(uint requestID, ConnectionType ctype)
@@ -678,7 +677,23 @@ namespace OSHttpServer
return ok;
}
public async Task<bool> SendAsync(byte[] buffer, int offset, int size)
private void SendAsyncEnd(IAsyncResult res)
{
try
{
m_stream.EndWrite(res);
m_currentResponse.CheckSendNextAsyncContinue();
}
catch (Exception e)
{
e.GetHashCode();
if(m_stream != null)
Disconnect(SocketError.NoRecovery);
}
ContextTimeoutManager.ContextLeaveActiveSend();
}
public bool SendAsyncStart(byte[] buffer, int offset, int size)
{
if (m_stream == null || m_sock == null || !m_sock.Connected)
return false;
@@ -690,15 +705,15 @@ namespace OSHttpServer
ContextTimeoutManager.ContextEnterActiveSend();
try
{
await m_stream.WriteAsync(buffer, offset, size).ConfigureAwait(false);
m_stream.BeginWrite(buffer, offset, size, SendAsyncEnd, null);
}
catch
catch (Exception e)
{
e.GetHashCode();
ContextTimeoutManager.ContextLeaveActiveSend();
ok = false;
}
ContextTimeoutManager.ContextLeaveActiveSend();
if (!ok && m_stream != null)
Disconnect(SocketError.NoRecovery);
return ok;