Skip to content

Commit

Permalink
Fix WSAEventSelect for win32. This is to fix the issue which uncovere…
Browse files Browse the repository at this point in the history
…d by FreeRDP#2750.

We used to fall in lool after FreeRDP#2750. The reason is that we attach to FD_WRITE event. This should not be expected. Because WSAEventSelect attaches to FD_WRITE, it is always in 'set' state even when we drain the read buffer.
It was first fixed in PR FreeRDP#2770. However the solution introduced another issue on Linux. This PR discards the fix in FreeRDP#2770
Later A quick fix for FreeRDP#2770 was introduced in FreeRDP#2790/FreeRDP#2791. It is also discarded together.
  • Loading branch information
realjiangms committed Sep 3, 2015
1 parent ad4a862 commit 6cba319
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion libfreerdp/core/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static int transport_bio_simple_init(BIO* bio, SOCKET socket, int shutdown)
return 0;

/* WSAEventSelect automatically sets the socket in non-blocking mode */
WSAEventSelect(ptr->socket, ptr->hEvent, FD_READ | FD_WRITE | FD_CLOSE);
WSAEventSelect(ptr->socket, ptr->hEvent, FD_READ | FD_CLOSE);
#else
ptr->hEvent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, (int) ptr->socket, WINPR_FD_READ);

Expand Down
7 changes: 0 additions & 7 deletions libfreerdp/core/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,24 +745,17 @@ int transport_check_fds(rdpTransport* transport)
int status;
int recv_status;
wStream* received;
HANDLE event;

if (!transport)
return -1;

if (BIO_get_event(transport->frontBio, &event) != 1)
return -1;

/**
* Loop through and read all available PDUs. Since multiple
* PDUs can exist, it's important to deliver them all before
* returning. Otherwise we run the risk of having a thread
* wait for a socket to get signaled that data is available
* (which may never happen).
*/
#ifdef _WIN32
ResetEvent(event);
#endif
for (;;)
{
/**
Expand Down

0 comments on commit 6cba319

Please sign in to comment.