From 7b23ed6f977059e0c95cdb72134932115557efc6 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Thu, 25 Aug 2011 13:30:17 +0800 Subject: [PATCH] libfreerdp-core/transport: prevent further read/write when socket is dropped. --- libfreerdp-core/transport.c | 6 ++++++ libfreerdp-core/transport.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libfreerdp-core/transport.c b/libfreerdp-core/transport.c index 4690b7e43..bbb62b30a 100644 --- a/libfreerdp-core/transport.c +++ b/libfreerdp-core/transport.c @@ -262,6 +262,12 @@ int transport_write(rdpTransport* transport, STREAM* s) stream_seek(s, status); } + if (status < 0) + { + /* A write error indicates that the peer has dropped the connection */ + transport->layer = TRANSPORT_LAYER_CLOSED; + } + return status; } diff --git a/libfreerdp-core/transport.h b/libfreerdp-core/transport.h index 8503ee06d..04a8735e3 100644 --- a/libfreerdp-core/transport.h +++ b/libfreerdp-core/transport.h @@ -23,7 +23,8 @@ typedef enum { TRANSPORT_LAYER_TCP, - TRANSPORT_LAYER_TLS + TRANSPORT_LAYER_TLS, + TRANSPORT_LAYER_CLOSED } TRANSPORT_LAYER; typedef struct rdp_transport rdpTransport;