# HG changeset patch
# User rosfran
# Date 1164665907 0
# Node ID ee3d9b05e4f251d43e2dfc1eaa4aa1ca7ea3f8f9
# Parent  96d4296e449240587ac8e801b6afbd8aa7b99555
[svn r121] Some changes to the BackendInfo.

diff -r 96d4296e4492 -r ee3d9b05e4f2 gmyth/src/gmyth_file_transfer.c
--- a/gmyth/src/gmyth_file_transfer.c	Mon Nov 27 22:07:59 2006 +0000
+++ b/gmyth/src/gmyth_file_transfer.c	Mon Nov 27 22:18:27 2006 +0000
@@ -86,9 +86,11 @@
 //static gboolean* myth_control_sock_listener( GIOChannel *io_channel );
 static gboolean myth_control_sock_listener( GIOChannel *io_channel, GIOCondition condition, gpointer data );
 
-static GMutex*			mutex 					 = NULL;
+static GMutex*				mutex 					 = NULL;
 
-static GCond*				io_watcher_cond  = NULL;
+static GCond*					io_watcher_cond  = NULL;
+
+static GMainContext*	io_watcher_context  = NULL;
 
 static void gmyth_file_transfer_class_init          (GMythFileTransferClass *klass);
 static void gmyth_file_transfer_init                (GMythFileTransfer *object);
@@ -173,8 +175,8 @@
   gboolean ret = TRUE;
 
   transfer->uri = gmyth_uri_new ( uri_str->str );
-  transfer->hostname = g_string_new( gmyth_uri_gethost(transfer->uri) );
-  transfer->port = gmyth_uri_getport( transfer->uri );
+  transfer->hostname = g_string_new( gmyth_uri_get_host(transfer->uri) );
+  transfer->port = gmyth_uri_get_port( transfer->uri );
 
   g_debug ("[%s] URI: %s\n", __FUNCTION__, uri_str->str);
   g_debug ("hostname: %s, port %d\n", transfer->hostname->str, transfer->port);
@@ -285,14 +287,15 @@
   GString *resp = gmyth_socket_receive_response( transfer->event_sock );
   g_print( "[%s] Got Monitor response from %s: %s\n", __FUNCTION__, base_str->str, resp->str );
   //g_thread_create( (GThreadFunc)myth_control_sock_listener, transfer->event_sock->sd_io_ch, TRUE, NULL );
-  //io_watcher_context = g_main_context_default();
+  io_watcher_context = g_main_context_default();
   GMainLoop *loop = g_main_loop_new( NULL, TRUE );
 
   //GSource *source;
 
-  if ( transfer->event_sock->sd_io_ch != NULL )
-    source_id = g_io_add_watch( transfer->event_sock->sd_io_ch, G_IO_IN , (GIOFunc)myth_control_sock_listener, NULL );
-  else {
+  if ( transfer->event_sock->sd_io_ch != NULL ) {
+    source_id = g_io_add_watch( transfer->event_sock->sd_io_ch, G_IO_IN, (GIOFunc)myth_control_sock_listener, NULL );
+    //transfer->event_sock->sd_io_ch
+  } else {
   	ret = FALSE;
   	goto cleanup;
   }
@@ -334,7 +337,7 @@
   g_return_val_if_fail (transfer->hostname != NULL, FALSE);
   g_return_val_if_fail (transfer->port > 0, FALSE);
 
-  gchar *path_dir = gmyth_uri_getpath (transfer->uri);
+  gchar *path_dir = gmyth_uri_get_path (transfer->uri);
 
   /* Creates the control socket */
   transfer->control_sock = gmyth_socket_new();
@@ -496,6 +499,7 @@
 {
 	
 	gboolean ret = TRUE;	
+	guint max_iter = 50;
 	
 	//g_mutex_lock( mutex );
 	
@@ -506,15 +510,13 @@
   
   //myth_control_acquire_context (FALSE);
   
-  /*
   g_mutex_lock( mutex );
   
   if ( do_wait ) {
-  	if ( !g_main_context_wait( io_watcher_context, io_watcher_cond, mutex ) )
+  	while ( --max_iter > 0 && !g_main_context_wait( io_watcher_context, io_watcher_cond, mutex ) )
   		ret = FALSE;
   } else if ( !g_main_context_acquire( io_watcher_context ) )
   	ret = FALSE;
-  	*/
   
   return ret;
   
@@ -526,9 +528,9 @@
 	
 	gboolean ret = TRUE;
 
-  //g_main_context_release( io_watcher_context );
+  g_main_context_release( io_watcher_context );
   
-  //g_mutex_unlock( mutex );
+  g_mutex_unlock( mutex );
   
   //has_io_access = TRUE;