Handle timeout in non-blocking send.
This commit is contained in:
parent
2b62c675fa
commit
645c572ab5
@ -582,12 +582,32 @@ size_t posixSocket::sendRawNonBlocking(const byte_t* buffer, const size_t count)
|
||||
if (ret < 0 && !IS_EAGAIN(errno))
|
||||
throwSocketError(errno);
|
||||
|
||||
// Check if we are timed out
|
||||
if (m_timeoutHandler &&
|
||||
m_timeoutHandler->isTimeOut())
|
||||
{
|
||||
if (!m_timeoutHandler->handleTimeOut())
|
||||
{
|
||||
// Could not send data within timeout delay
|
||||
throwSocketError(errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset timeout
|
||||
m_timeoutHandler->resetTimeOut();
|
||||
}
|
||||
}
|
||||
|
||||
m_status |= STATUS_WOULDBLOCK;
|
||||
|
||||
// No data can be written at this time
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Reset timeout
|
||||
if (m_timeoutHandler)
|
||||
m_timeoutHandler->resetTimeOut();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -362,6 +362,22 @@ size_t windowsSocket::sendRawNonBlocking(const char* buffer, const size_t count)
|
||||
|
||||
if (err == WSAEWOULDBLOCK)
|
||||
{
|
||||
// Check if we are timed out
|
||||
if (m_timeoutHandler &&
|
||||
m_timeoutHandler->isTimeOut())
|
||||
{
|
||||
if (!m_timeoutHandler->handleTimeOut())
|
||||
{
|
||||
// Could not send data within timeout delay
|
||||
throwSocketError(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset timeout
|
||||
m_timeoutHandler->resetTimeOut();
|
||||
}
|
||||
}
|
||||
|
||||
m_status |= STATUS_WOULDBLOCK;
|
||||
|
||||
// No data can be written at this time
|
||||
@ -373,6 +389,10 @@ size_t windowsSocket::sendRawNonBlocking(const char* buffer, const size_t count)
|
||||
}
|
||||
}
|
||||
|
||||
// Reset timeout
|
||||
if (m_timeoutHandler)
|
||||
m_timeoutHandler->resetTimeOut();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user