summaryrefslogtreecommitdiffstats
path: root/libxrdp/xrdp_mcs.c
diff options
context:
space:
mode:
Diffstat (limited to 'libxrdp/xrdp_mcs.c')
-rw-r--r--libxrdp/xrdp_mcs.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c
index 77c0d10d..dbcb0955 100644
--- a/libxrdp/xrdp_mcs.c
+++ b/libxrdp/xrdp_mcs.c
@@ -19,6 +19,7 @@
*/
#include "libxrdp.h"
+#include "log.h"
/*****************************************************************************/
struct xrdp_mcs *APP_CC
@@ -146,12 +147,12 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
{
in_uint16_be(s, userid);
in_uint16_be(s, chanid);
- g_writeln("channel join request received %d:%d", userid, chanid);
+ log_message(LOG_LEVEL_DEBUG,"MCS_CJRQ - channel join request received");
DEBUG(("xrdp_mcs_recv adding channel %4.4x", chanid));
if (xrdp_mcs_send_cjcf(self, userid, chanid) != 0)
{
- g_writeln("Non handled error from xrdp_mcs_send_cjcf") ;
+ log_message(LOG_LEVEL_ERROR,"Non handled error from xrdp_mcs_send_cjcf") ;
}
continue;
@@ -163,7 +164,7 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
}
else
{
- g_writeln("Recieved an unhandled appid:%d", appid);
+ log_message(LOG_LEVEL_DEBUG,"Recieved an unhandled appid:%d",appid);
}
break;
@@ -819,6 +820,25 @@ xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan)
return 0;
}
+/**
+ * Internal help function to close the socket
+ * @param self
+ */
+void close_rdp_socket(struct xrdp_mcs *self)
+{
+ if(self->iso_layer->tcp_layer)
+ {
+ if(self->iso_layer->tcp_layer->trans)
+ {
+ g_tcp_close(self->iso_layer->tcp_layer->trans->sck);
+ self->iso_layer->tcp_layer->trans->sck = 0 ;
+ g_writeln("xrdp_mcs_disconnect - socket closed");
+ return ;
+ }
+ }
+ g_writeln("Failed to close socket");
+}
+
/*****************************************************************************/
/* returns error */
int APP_CC
@@ -833,7 +853,8 @@ xrdp_mcs_disconnect(struct xrdp_mcs *self)
if (xrdp_iso_init(self->iso_layer, s) != 0)
{
free_stream(s);
- DEBUG((" out xrdp_mcs_disconnect error"));
+ close_rdp_socket(self);
+ DEBUG((" out xrdp_mcs_disconnect error - 1"));
return 1;
}
@@ -844,11 +865,13 @@ xrdp_mcs_disconnect(struct xrdp_mcs *self)
if (xrdp_iso_send(self->iso_layer, s) != 0)
{
free_stream(s);
- DEBUG((" out xrdp_mcs_disconnect error"));
+ close_rdp_socket(self);
+ DEBUG((" out xrdp_mcs_disconnect error - 2"));
return 1;
}
free_stream(s);
- DEBUG((" out xrdp_mcs_disconnect"));
+ close_rdp_socket(self);
+ DEBUG(("xrdp_mcs_disconnect - close sent"));
return 0;
}