Fixed Windows http timeout #2451. (#2452)

This commit is contained in:
tomaz-beltram 2018-09-04 15:20:10 +02:00 committed by Alex Fabijanic
parent c8af3f1c92
commit f140808fab
2 changed files with 11 additions and 10 deletions

View File

@ -490,7 +490,7 @@ protected:
void reset(poco_socket_t fd = POCO_INVALID_SOCKET);
/// Allows subclasses to set the socket manually, iff no valid socket is set yet.
void checkBrokenTimeout();
void checkBrokenTimeout(const SelectMode& mode);
static int lastError();
/// Returns the last error code.

View File

@ -306,13 +306,14 @@ void SocketImpl::shutdown()
}
void SocketImpl::checkBrokenTimeout()
void SocketImpl::checkBrokenTimeout(const SelectMode& mode)
{
if (_isBrokenTimeout)
{
if (_recvTimeout.totalMicroseconds() != 0)
Poco::Timespan timeout = (mode == SelectMode::SELECT_READ) ? _recvTimeout : _sndTimeout;
if (timeout.totalMicroseconds() != 0)
{
if (!poll(_recvTimeout, SELECT_READ))
if (!poll(timeout, mode))
throw TimeoutException();
}
}
@ -321,7 +322,7 @@ void SocketImpl::checkBrokenTimeout()
int SocketImpl::sendBytes(const void* buffer, int length, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_WRITE);
int rc;
do
@ -337,7 +338,7 @@ int SocketImpl::sendBytes(const void* buffer, int length, int flags)
int SocketImpl::sendBytes(const SocketBufVec& buffers, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_WRITE);
int rc = 0;
do
@ -362,7 +363,7 @@ int SocketImpl::sendBytes(const SocketBufVec& buffers, int flags)
int SocketImpl::receiveBytes(void* buffer, int length, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_READ);
int rc;
do
@ -387,7 +388,7 @@ int SocketImpl::receiveBytes(void* buffer, int length, int flags)
int SocketImpl::receiveBytes(SocketBufVec& buffers, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_READ);
int rc = 0;
do
@ -516,7 +517,7 @@ int SocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, in
int SocketImpl::receiveFrom(void* buffer, int length, struct sockaddr** ppSA, poco_socklen_t** ppSALen, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_READ);
int rc;
do
{
@ -555,7 +556,7 @@ int SocketImpl::receiveFrom(SocketBufVec& buffers, SocketAddress& address, int f
int SocketImpl::receiveFrom(SocketBufVec& buffers, struct sockaddr** pSA, poco_socklen_t** ppSALen, int flags)
{
checkBrokenTimeout();
checkBrokenTimeout(SELECT_READ);
int rc = 0;
do
{