Using auto reset event now.
authorArmin Novak <armin.novak@thincast.com>
Mon, 20 Apr 2015 12:43:37 +0000 (14:43 +0200)
committerArmin Novak <armin.novak@thincast.com>
Mon, 20 Apr 2015 13:04:44 +0000 (15:04 +0200)
libfreerdp/core/tcp.c

index b357bc5..0cf9e81 100644 (file)
@@ -98,21 +98,6 @@ typedef struct _WINPR_BIO_SIMPLE_SOCKET WINPR_BIO_SIMPLE_SOCKET;
 static int transport_bio_simple_init(BIO* bio, SOCKET socket, int shutdown);
 static int transport_bio_simple_uninit(BIO* bio);
 
-static void transport_bio_simple_check_reset_event(BIO* bio)
-{
-       u_long nbytes = 0;
-       WINPR_BIO_SIMPLE_SOCKET* ptr = (WINPR_BIO_SIMPLE_SOCKET*) bio->ptr;
-
-#ifndef _WIN32
-       return;
-#endif
-
-       _ioctlsocket(ptr->socket, FIONREAD, &nbytes);
-
-       if (nbytes < 1)
-               WSAResetEvent(ptr->hEvent);
-}
-
 long transport_bio_simple_callback(BIO* bio, int mode, const char* argp, int argi, long argl, long ret)
 {
        return 1;
@@ -164,7 +149,6 @@ static int transport_bio_simple_read(BIO* bio, char* buf, int size)
 
        if (status > 0)
        {
-               transport_bio_simple_check_reset_event(bio);
                return status;
        }
 
@@ -186,8 +170,6 @@ static int transport_bio_simple_read(BIO* bio, char* buf, int size)
                BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
        }
 
-       transport_bio_simple_check_reset_event(bio);
-
        return -1;
 }
 
@@ -378,13 +360,13 @@ static int transport_bio_simple_init(BIO* bio, SOCKET socket, int shutdown)
        bio->init = 1;
 
 #ifdef _WIN32
-               ptr->hEvent = WSACreateEvent(); /* creates a manual reset event */
+               ptr->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
 
                if (!ptr->hEvent)
                        return 0;
 
                /* WSAEventSelect automatically sets the socket in non-blocking mode */
-               WSAEventSelect(ptr->socket, ptr->hEvent, FD_READ | FD_CLOSE);
+               WSAEventSelect(ptr->socket, ptr->hEvent, FD_READ | FD_WRITE | FD_CLOSE);
 #else
                ptr->hEvent = CreateFileDescriptorEvent(NULL, FALSE, FALSE, (int) ptr->socket);