libfreerdp-core: properly attach tcp event handle for peers
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 21 Jul 2013 02:34:05 +0000 (22:34 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 21 Jul 2013 02:34:05 +0000 (22:34 -0400)
include/freerdp/peer.h
libfreerdp/core/peer.c
libfreerdp/core/tcp.c
libfreerdp/core/tcp.h
libfreerdp/core/transport.c

index 6279c92..e447ba0 100644 (file)
@@ -33,6 +33,7 @@ typedef void (*psPeerContextFree)(freerdp_peer* client, rdpContext* context);
 
 typedef BOOL (*psPeerInitialize)(freerdp_peer* client);
 typedef BOOL (*psPeerGetFileDescriptor)(freerdp_peer* client, void** rfds, int* rcount);
+typedef HANDLE (*psPeerGetEventHandle)(freerdp_peer* client);
 typedef BOOL (*psPeerCheckFileDescriptor)(freerdp_peer* client);
 typedef BOOL (*psPeerClose)(freerdp_peer* client);
 typedef void (*psPeerDisconnect)(freerdp_peer* client);
@@ -60,6 +61,7 @@ struct rdp_freerdp_peer
 
        psPeerInitialize Initialize;
        psPeerGetFileDescriptor GetFileDescriptor;
+       psPeerGetEventHandle GetEventHandle;
        psPeerCheckFileDescriptor CheckFileDescriptor;
        psPeerClose Close;
        psPeerDisconnect Disconnect;
index c769b40..5b38c90 100644 (file)
@@ -54,6 +54,11 @@ static BOOL freerdp_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
        return TRUE;
 }
 
+static HANDLE freerdp_peer_get_event_handle(freerdp_peer* client)
+{
+       return client->context->rdp->transport->TcpIn->event;
+}
+
 static BOOL freerdp_peer_check_fds(freerdp_peer* client)
 {
        int status;
@@ -432,12 +437,13 @@ freerdp_peer* freerdp_peer_new(int sockfd)
 
        freerdp_tcp_set_no_delay(sockfd, TRUE);
 
-       if (client != NULL)
+       if (client)
        {
                client->sockfd = sockfd;
                client->ContextSize = sizeof(rdpContext);
                client->Initialize = freerdp_peer_initialize;
                client->GetFileDescriptor = freerdp_peer_get_fds;
+               client->GetEventHandle = freerdp_peer_get_event_handle;
                client->CheckFileDescriptor = freerdp_peer_check_fds;
                client->Close = freerdp_peer_close;
                client->Disconnect = freerdp_peer_disconnect;
index a0ad864..908e06a 100644 (file)
@@ -253,6 +253,13 @@ BOOL tcp_set_keep_alive_mode(rdpTcp* tcp)
        return TRUE;
 }
 
+int tcp_attach(rdpTcp* tcp, int sockfd)
+{
+       tcp->sockfd = sockfd;
+       SetEventFileDescriptor(tcp->event, tcp->sockfd);
+       return 0;
+}
+
 HANDLE tcp_get_event_handle(rdpTcp* tcp)
 {
 #ifndef _WIN32
index 539d776..c22e5da 100644 (file)
@@ -56,6 +56,7 @@ int tcp_wait_read(rdpTcp* tcp);
 int tcp_wait_write(rdpTcp* tcp);
 BOOL tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking);
 BOOL tcp_set_keep_alive_mode(rdpTcp* tcp);
+int tcp_attach(rdpTcp* tcp, int sockfd);
 HANDLE tcp_get_event_handle(rdpTcp* tcp);
 
 rdpTcp* tcp_new(rdpSettings* settings);
index 4088544..03ffb29 100644 (file)
@@ -64,8 +64,7 @@ wStream* transport_send_stream_init(rdpTransport* transport, int size)
 
 void transport_attach(rdpTransport* transport, int sockfd)
 {
-       transport->TcpIn->sockfd = sockfd;
-
+       tcp_attach(transport->TcpIn, sockfd);
        transport->SplitInputOutput = FALSE;
        transport->TcpOut = transport->TcpIn;
 }