Fix peeking into an already closed socket
Crazily enough, this seems to have been broken ever since a324a7bccf
(Added GSocket for Unix [...], 1999-07-22) which removed the call to
GetPushback(true) from Peek(), making its "peek" parameter unused until
now.
Restore this call in order to return the correct data from the internal
buffer even if the socket has been closed since the last read.
This fixes wxURI tests as the new test HTTP server returns smaller
response which can be typically read entirely at once.
This commit is contained in:
parent
b5d7112583
commit
001fbe120f
1 changed files with 8 additions and 0 deletions
|
|
@ -1131,6 +1131,14 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
|
|||
|
||||
wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
|
||||
{
|
||||
// If we're already closed, don't try switching the invalid socket into
|
||||
// non-blocking mode, but still use the already read data, if any.
|
||||
if ( m_impl->m_fd == INVALID_SOCKET )
|
||||
{
|
||||
m_lcount = GetPushback(buffer, nbytes, true);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxSocketReadGuard read(this);
|
||||
|
||||
// Peek() should never block
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue