set error to GSOCK_TIMEOUT if the socket timed out (modified and extended patch 1303554)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -726,7 +726,10 @@ int GSocket::Read(char *buffer, int size)
|
|||||||
|
|
||||||
/* If the socket is blocking, wait for data (with a timeout) */
|
/* If the socket is blocking, wait for data (with a timeout) */
|
||||||
if (Input_Timeout() == GSOCK_TIMEDOUT)
|
if (Input_Timeout() == GSOCK_TIMEDOUT)
|
||||||
|
{
|
||||||
|
m_error = GSOCK_TIMEDOUT;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read the data */
|
/* Read the data */
|
||||||
if (m_stream)
|
if (m_stream)
|
||||||
|
@@ -869,24 +869,26 @@ int GSocket::Read(char *buffer, int size)
|
|||||||
Disable(GSOCK_INPUT);
|
Disable(GSOCK_INPUT);
|
||||||
|
|
||||||
/* If the socket is blocking, wait for data (with a timeout) */
|
/* If the socket is blocking, wait for data (with a timeout) */
|
||||||
if (Input_Timeout() == GSOCK_TIMEDOUT)
|
if (Input_Timeout() == GSOCK_TIMEDOUT) {
|
||||||
/* We no longer return here immediately, otherwise socket events would not be re-enabled! */
|
m_error = GSOCK_TIMEDOUT;
|
||||||
|
/* Don't return here immediately, otherwise socket events would not be
|
||||||
|
* re-enabled! */
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* Read the data */
|
/* Read the data */
|
||||||
if (m_stream)
|
if (m_stream)
|
||||||
ret = Recv_Stream(buffer, size);
|
ret = Recv_Stream(buffer, size);
|
||||||
else
|
else
|
||||||
ret = Recv_Dgram(buffer, size);
|
ret = Recv_Dgram(buffer, size);
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1) {
|
||||||
{
|
|
||||||
if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
|
if ((errno == EWOULDBLOCK) || (errno == EAGAIN))
|
||||||
m_error = GSOCK_WOULDBLOCK;
|
m_error = GSOCK_WOULDBLOCK;
|
||||||
else
|
else
|
||||||
m_error = GSOCK_IOERR;
|
m_error = GSOCK_IOERR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable events again now that we are done processing */
|
/* Enable events again now that we are done processing */
|
||||||
Enable(GSOCK_INPUT);
|
Enable(GSOCK_INPUT);
|
||||||
|
Reference in New Issue
Block a user