# HG changeset patch
# User rosfran
# Date 1165264996 0
# Node ID 08b70ec67aa45e0cc16353646cd4155adb84eb81
# Parent  1b4e66e09d433555313b6a7e9408b85e681c4c97
[svn r187] Fixes the sg fault on file transfer.

diff -r 1b4e66e09d43 -r 08b70ec67aa4 gmyth/src/gmyth_file_transfer.c
--- a/gmyth/src/gmyth_file_transfer.c	Mon Dec 04 19:58:40 2006 +0000
+++ b/gmyth/src/gmyth_file_transfer.c	Mon Dec 04 20:43:16 2006 +0000
@@ -174,6 +174,8 @@
   GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL));
   
   transfer->uri = gmyth_uri_new_with_value (uri_str);
+  transfer->hostname = g_string_new( gmyth_uri_get_host(transfer->uri) );
+  transfer->port = gmyth_uri_get_port( transfer->uri );
 
   return transfer;
 }
@@ -187,9 +189,6 @@
   
   if ( filename != NULL )
   {
-		transfer->uri = gmyth_uri_new_with_value ( filename );
-  	transfer->hostname = g_string_new( gmyth_uri_get_host(transfer->uri) );
-  	transfer->port = gmyth_uri_get_port( transfer->uri );
   	transfer->filename = filename;
   	gmyth_backend_info_set_path ( transfer->backend_info, filename );
   }
@@ -201,7 +200,8 @@
 	  transfer->port = gmyth_backend_info_get_port (transfer->backend_info);
   }
   
-  gmyth_debug ("[%s] URI: %s\n", __FUNCTION__, transfer->uri->uri->str);
+  if ( transfer->uri )  
+  	gmyth_debug ("[%s] URI: %s\n", __FUNCTION__, transfer->uri->uri->str);
 	 
   gmyth_debug ("hostname: %s, port %d\n", transfer->hostname->str, transfer->port);
   
diff -r 1b4e66e09d43 -r 08b70ec67aa4 gmyth/src/gmyth_monitor_handler.c
--- a/gmyth/src/gmyth_monitor_handler.c	Mon Dec 04 19:58:40 2006 +0000
+++ b/gmyth/src/gmyth_monitor_handler.c	Mon Dec 04 20:43:16 2006 +0000
@@ -208,7 +208,7 @@
   
   //GMythMonitorHandler *monitor = (GMythMonitorHandler*)data;
   
-  //*ret = TRUE;
+  *ret = TRUE;
   //myth_control_acquire_context (TRUE);
   
   if ( io_channel == NULL ) {
@@ -220,7 +220,7 @@
   
   while (TRUE) {
 	  	
-	  //condition = g_io_channel_get_buffer_condition( io_channel );
+	  condition = g_io_channel_get_buffer_condition( io_channel );
 	  
 	  //myth_control_acquire_context (TRUE);
 	  
@@ -232,7 +232,7 @@
 	  if (condition & G_IO_HUP) {
 	    gmyth_debug ("Read end of pipe died!\n");
 	    *ret = FALSE;
-	    goto clean_up;
+	    //goto clean_up;
 	  }
 	    
 	  if ( ( condition & G_IO_IN ) != 0 ) {
@@ -259,6 +259,12 @@
 	      io_cond = g_io_channel_get_buffer_condition( io_channel );
 	
 	    } while ( ( io_cond & G_IO_IN ) != 0 );
+	    gmyth_debug ("\n[%s]\tEVENT: Read %d bytes: %s\n\n", __FUNCTION__, recv, byte_array != NULL && byte_array->data != NULL ? (gchar*)byte_array->data : "[no event data]" );
+	  }	  
+	  
+	  if ( byte_array != NULL ) {
+	  	g_byte_array_free( byte_array, TRUE );
+	  	byte_array = NULL;
 	  }
 	  
 	  g_usleep( 300 );
@@ -270,17 +276,11 @@
    	*ret = FALSE;
    	goto clean_up;   	
   }
-  gmyth_debug ("\n[%s]\tEVENT: Read %d bytes: %s\n\n", __FUNCTION__, recv, byte_array->data != NULL ? (gchar*)byte_array->data : "[no event data]" );
   
   //g_hash_table_insert( monitor->backend_msgs, (gpointer)monitor->actual_index,
   //				  byte_array->data );
   
   //monitor->actual_index += recv;
-  
-  if ( byte_array != NULL ) {
-  	g_byte_array_free( byte_array, TRUE );
-  	byte_array = NULL;
-  }
 
 clean_up: