[*] Minor net fixes
[*] Fix async shutdown / inline shutdown condition [*] Fix multiple net triggers [*] Fix spurious UDP Session Socket timeouts
This commit is contained in:
parent
a2322470b8
commit
1fb36548ea
@ -314,7 +314,7 @@ namespace Aurora::IO::Net
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!this->socketChannel_.outputChannel.AsWritableByteBuffer()->RemainingBytes())
|
if (this->socketChannel_.outputChannel.CanShutdown())
|
||||||
{
|
{
|
||||||
this->Shutdown(true);
|
this->Shutdown(true);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ namespace Aurora::IO::Net
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!this->socketChannel_.outputChannel.AsWritableByteBuffer()->RemainingBytes())
|
if (this->socketChannel_.outputChannel.CanShutdown())
|
||||||
{
|
{
|
||||||
this->Shutdown(true);
|
this->Shutdown(true);
|
||||||
}
|
}
|
||||||
|
@ -318,6 +318,8 @@ namespace Aurora::IO::Net
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->connectOperation.ReleaseWatcher();
|
||||||
|
|
||||||
auto pDriver = this->pSocketDriver_;
|
auto pDriver = this->pSocketDriver_;
|
||||||
if (bool(pDriver))
|
if (bool(pDriver))
|
||||||
{
|
{
|
||||||
@ -635,6 +637,7 @@ namespace Aurora::IO::Net
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->connectOperation.ReleaseWatcher();
|
||||||
this->socketChannel_.StopTime();
|
this->socketChannel_.StopTime();
|
||||||
|
|
||||||
this->pWorker_->RemoveSocket(this);
|
this->pWorker_->RemoveSocket(this);
|
||||||
|
@ -263,6 +263,11 @@ namespace Aurora::IO::Net
|
|||||||
return this->outputWriteQueue_.IsEmpty() && AuAtomicLoad(&this->uCompleteCounter_) == 0;
|
return this->outputWriteQueue_.IsEmpty() && AuAtomicLoad(&this->uCompleteCounter_) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SocketChannelOutput::CanShutdown()
|
||||||
|
{
|
||||||
|
return this->CanResize() && !this->AsWritableByteBuffer()->RemainingBytes();
|
||||||
|
}
|
||||||
|
|
||||||
void SocketChannelOutput::OnAsyncFileOpFinished(AuUInt64 offset, AuUInt32 length)
|
void SocketChannelOutput::OnAsyncFileOpFinished(AuUInt64 offset, AuUInt32 length)
|
||||||
{
|
{
|
||||||
AuAtomicSub(&this->outputBuffer_.uInUseCounter, 1u);
|
AuAtomicSub(&this->outputBuffer_.uInUseCounter, 1u);
|
||||||
|
@ -37,6 +37,7 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuByteBuffer &GetByteBuffer();
|
AuByteBuffer &GetByteBuffer();
|
||||||
bool CanResize();
|
bool CanResize();
|
||||||
|
bool CanShutdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct SocketBase;
|
friend struct SocketBase;
|
||||||
|
@ -49,9 +49,24 @@ namespace Aurora::IO::Net
|
|||||||
if (dwErrorCode == ERROR_IO_PENDING)
|
if (dwErrorCode == ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
this->pSocket = that;
|
this->pSocket = that;
|
||||||
SysAssert(pWorker->ToProcessor()->StartSimpleLSWatchEx(this->pEvent,
|
|
||||||
|
if (auto pOld = AuTryLockMemoryType(this->wpThat))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto pThat = pWorker->ToProcessor()->StartSimpleLSWatchEx(this->pEvent,
|
||||||
AuSPtr<AuIO::IIOSimpleEventListener>(that, this),
|
AuSPtr<AuIO::IIOSimpleEventListener>(that, this),
|
||||||
true));
|
!this->bMultipleTrigger);
|
||||||
|
if (!pThat)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->wpThat = pThat;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -64,6 +79,16 @@ namespace Aurora::IO::Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketOverlappedOperation::ReleaseWatcher()
|
||||||
|
{
|
||||||
|
if (auto pOld = AuTryLockMemoryType(this->wpThat))
|
||||||
|
{
|
||||||
|
pOld->StopWatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
AuResetMember(this->wpThat);
|
||||||
|
}
|
||||||
|
|
||||||
bool SocketOverlappedOperation::IsValid()
|
bool SocketOverlappedOperation::IsValid()
|
||||||
{
|
{
|
||||||
return bool(this->pEvent);
|
return bool(this->pEvent);
|
||||||
|
@ -49,7 +49,10 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
bool IsValid();
|
bool IsValid();
|
||||||
|
|
||||||
|
void ReleaseWatcher();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool bHasFlipped {};
|
bool bHasFlipped {};
|
||||||
|
AuWPtr<IIOProcessorItem> wpThat;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -68,24 +68,41 @@ namespace Aurora::IO::Net
|
|||||||
bool SocketOverlappedOperation::BeginOperation(const AuSPtr<void> &that,
|
bool SocketOverlappedOperation::BeginOperation(const AuSPtr<void> &that,
|
||||||
const AuSPtr<INetWorker> &pWorker)
|
const AuSPtr<INetWorker> &pWorker)
|
||||||
{
|
{
|
||||||
this->pSocket = that;
|
|
||||||
if (!this->pEvent)
|
if (!this->pEvent)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bStatus = pWorker->ToProcessor()->StartSimpleLSWatchEx(this->pEvent,
|
this->pSocket = that;
|
||||||
|
|
||||||
|
if (auto pOld = AuTryLockMemoryType(this->wpThat))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pThat = pWorker->ToProcessor()->StartSimpleLSWatchEx(this->pEvent,
|
||||||
AuSPtr<AuIO::IIOSimpleEventListener>(that, this),
|
AuSPtr<AuIO::IIOSimpleEventListener>(that, this),
|
||||||
true);
|
!this->bMultipleTrigger);
|
||||||
if (!bStatus)
|
if (!pThat)
|
||||||
{
|
{
|
||||||
this->pSocket.reset();
|
this->pSocket.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->wpThat = pThat;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketOverlappedOperation::ReleaseWatcher()
|
||||||
|
{
|
||||||
|
if (auto pOld = AuTryLockMemoryType(this->wpThat))
|
||||||
|
{
|
||||||
|
pOld->StopWatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
AuResetMember(this->wpThat);
|
||||||
|
}
|
||||||
|
|
||||||
void SocketOverlappedOperation::UpdateTrigger(const AuSPtr<AuLoop::ILoopSource> &pTrigger)
|
void SocketOverlappedOperation::UpdateTrigger(const AuSPtr<AuLoop::ILoopSource> &pTrigger)
|
||||||
{
|
{
|
||||||
this->pEvent = pTrigger;
|
this->pEvent = pTrigger;
|
||||||
|
@ -53,8 +53,10 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
bool IsValid();
|
bool IsValid();
|
||||||
|
|
||||||
|
void ReleaseWatcher();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool bHasFlipped {};
|
bool bHasFlipped {};
|
||||||
|
AuWPtr<IIOProcessorItem> wpThat;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -136,5 +136,6 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
void SocketServerImpl::DetroyServer()
|
void SocketServerImpl::DetroyServer()
|
||||||
{
|
{
|
||||||
|
this->acceptOperation_.ReleaseWatcher();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
this->Start();
|
this->Start();
|
||||||
this->calculator.AddData(uBytes);
|
this->calculator.AddData(uBytes);
|
||||||
|
this->uLastTimeSteadyMS = AuTime::SteadyClockMS();
|
||||||
}
|
}
|
||||||
|
|
||||||
AuInt64 SocketStats::GetFirstTickTimeMS()
|
AuInt64 SocketStats::GetFirstTickTimeMS()
|
||||||
|
@ -32,8 +32,9 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
auto uLastRecv = pSession->channel.GetRecvStatsEx().uLastTimeSteadyMS;
|
auto uLastRecv = pSession->channel.GetRecvStatsEx().uLastTimeSteadyMS;
|
||||||
auto uLastSend = pSession->channel.GetSendStatsEx().uLastTimeSteadyMS;
|
auto uLastSend = pSession->channel.GetSendStatsEx().uLastTimeSteadyMS;
|
||||||
if ((uSocketTimeoutRecvMS && (uLastRecv + uSocketTimeoutRecvMS < uNow)) ||
|
if ((uSocketTimeoutRecvMS && (uLastRecv && (uLastRecv + uSocketTimeoutRecvMS < uNow))) ||
|
||||||
(uSocketTimeoutAnyMS && ((uLastRecv + uSocketTimeoutAnyMS < uNow) || (uLastSend + uSocketTimeoutAnyMS < uNow))))
|
(uSocketTimeoutAnyMS && ((uLastRecv && (uLastRecv + uSocketTimeoutAnyMS < uNow)) ||
|
||||||
|
(uLastSend && (uLastSend + uSocketTimeoutAnyMS < uNow)))))
|
||||||
{
|
{
|
||||||
abortions[pSession->pWorker].push_back(pSession);
|
abortions[pSession->pWorker].push_back(pSession);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user