diff options
author | Giovanni Panozzo <giovanni@panozzo.it> | 2014-10-18 02:04:13 +0400 |
---|---|---|
committer | Giovanni Panozzo <giovanni@panozzo.it> | 2014-10-18 02:12:09 +0400 |
commit | 210e8a92130b5638ff77deaa9d7344c566861aa2 (patch) | |
tree | b9b4f5d4faf4d762225dfe517b25ac6463698a14 /remmina-plugins/rdp | |
parent | 9090480a62920060a0b2f36ec97063c61ae9fa0a (diff) |
Fix freerdp connection closing
Diffstat (limited to 'remmina-plugins/rdp')
-rw-r--r-- | remmina-plugins/rdp/rdp_plugin.c | 38 | ||||
-rw-r--r-- | remmina-plugins/rdp/rdp_plugin.h | 6 |
2 files changed, 31 insertions, 13 deletions
diff --git a/remmina-plugins/rdp/rdp_plugin.c b/remmina-plugins/rdp/rdp_plugin.c index 39c8faa12..fadacffab 100644 --- a/remmina-plugins/rdp/rdp_plugin.c +++ b/remmina-plugins/rdp/rdp_plugin.c @@ -338,6 +338,7 @@ static BOOL remmina_rdp_post_connect(freerdp* instance) instance->update->DesktopResize = rf_desktop_resize; freerdp_channels_post_connect(instance->context->channels, instance); + rfi->connected = True; remmina_plugin_service->protocol_plugin_emit_signal(gp, "connect"); @@ -642,7 +643,7 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget* gp) dest_server = remmina_plugin_service->file_get_string(remminafile, "server"); if ( dest_server ) { remmina_plugin_service->get_server_port(dest_server, 0, &dest_host, &dest_port); - rfi->settings->CertificateName = _strdup( dest_host ); + rfi->settings->CertificateName = strdup( dest_host ); g_free(dest_host); } } @@ -679,12 +680,17 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget* gp) if (remmina_plugin_service->file_get_string(remminafile, "clientname")) { - strncpy(rfi->settings->ClientHostname, remmina_plugin_service->file_get_string(remminafile, "clientname"), - sizeof(rfi->settings->ClientHostname) - 1); + s = remmina_plugin_service->file_get_string(remminafile, "clientname"); + if ( s ) { + free( rfi->settings->ClientHostname ); + rfi->settings->ClientHostname = strdup(s); + g_free(s); + } } else { - strncpy(rfi->settings->ClientHostname, g_get_host_name(), sizeof(rfi->settings->ClientHostname) - 1); + free( rfi->settings->ClientHostname ); + rfi->settings->ClientHostname = strdup( g_get_host_name() ); } if (remmina_plugin_service->file_get_string(remminafile, "exec")) @@ -919,6 +925,7 @@ static void remmina_rdp_init(RemminaProtocolWidget* gp) rfi->instance = instance; rfi->settings = instance->settings; rfi->instance->context->channels = freerdp_channels_new(); + rfi->connected = False; pthread_mutex_init(&rfi->mutex, NULL); @@ -976,13 +983,11 @@ static gboolean remmina_rdp_close_connection(RemminaProtocolWidget* gp) if (instance) { - if (instance->context->channels) - { - //freerdp_channels_close(rfi->channels, instance); - freerdp_channels_free(instance->context->channels); - instance->context->channels = NULL; + if ( rfi->connected ) { + if (instance->context->channels) + freerdp_channels_close(instance->context->channels, instance); + freerdp_disconnect(instance); } - freerdp_disconnect(instance); } if (rfi->rfx_context) @@ -993,8 +998,19 @@ static gboolean remmina_rdp_close_connection(RemminaProtocolWidget* gp) if (instance) { - //freerdp_context_free(instance); /* context is rfContext* rfi */ + /* Remove instance->context from gp object data to avoid double free */ + g_object_steal_data(G_OBJECT(gp), "plugin-data"); + + + + if (instance->context->channels) { + freerdp_channels_free(instance->context->channels); + instance->context->channels = NULL; + } + + freerdp_context_free(instance); /* context is rfContext* rfi */ freerdp_free(instance); + rfi->instance = NULL; } return FALSE; diff --git a/remmina-plugins/rdp/rdp_plugin.h b/remmina-plugins/rdp/rdp_plugin.h index ef00f5347..35395c5d5 100644 --- a/remmina-plugins/rdp/rdp_plugin.h +++ b/remmina-plugins/rdp/rdp_plugin.h @@ -1,6 +1,6 @@ /* * Remmina - The GTK+ Remote Desktop Client - * Copyright (C) 2010-2011 Vic Lee + * Copyright (C) 2010-2011 Vic Lee * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, + * Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * In addition, as a special exception, the copyright holders give @@ -106,6 +106,8 @@ struct rf_context RFX_CONTEXT* rfx_context; + gboolean connected; + gboolean sw_gdi; GtkWidget* drawing_area; gint scale_width; |