diff options
| author | Vincent Richard <[email protected]> | 2013-12-17 21:38:45 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2013-12-17 21:38:45 +0000 |
| commit | 645c572ab5b510967a5475743bed45c9e54439eb (patch) | |
| tree | d0ca6b48eb826c65c8ea4eff4a29fb078702cc8f /src/platforms/posix/posixSocket.cpp | |
| parent | Loop on recv and send operations for non-blocking sockets with OpenSSL. (diff) | |
| download | vmime-645c572ab5b510967a5475743bed45c9e54439eb.tar.gz vmime-645c572ab5b510967a5475743bed45c9e54439eb.zip | |
Handle timeout in non-blocking send.
Diffstat (limited to 'src/platforms/posix/posixSocket.cpp')
| -rw-r--r-- | src/platforms/posix/posixSocket.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/platforms/posix/posixSocket.cpp b/src/platforms/posix/posixSocket.cpp index e245bd95..ab434116 100644 --- a/src/platforms/posix/posixSocket.cpp +++ b/src/platforms/posix/posixSocket.cpp @@ -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; } |
