[svn r121] Some changes to the BackendInfo.
1.1 --- a/gmyth/src/gmyth_file_transfer.c Mon Nov 27 22:07:59 2006 +0000
1.2 +++ b/gmyth/src/gmyth_file_transfer.c Mon Nov 27 22:18:27 2006 +0000
1.3 @@ -86,9 +86,11 @@
1.4 //static gboolean* myth_control_sock_listener( GIOChannel *io_channel );
1.5 static gboolean myth_control_sock_listener( GIOChannel *io_channel, GIOCondition condition, gpointer data );
1.6
1.7 -static GMutex* mutex = NULL;
1.8 +static GMutex* mutex = NULL;
1.9
1.10 -static GCond* io_watcher_cond = NULL;
1.11 +static GCond* io_watcher_cond = NULL;
1.12 +
1.13 +static GMainContext* io_watcher_context = NULL;
1.14
1.15 static void gmyth_file_transfer_class_init (GMythFileTransferClass *klass);
1.16 static void gmyth_file_transfer_init (GMythFileTransfer *object);
1.17 @@ -173,8 +175,8 @@
1.18 gboolean ret = TRUE;
1.19
1.20 transfer->uri = gmyth_uri_new ( uri_str->str );
1.21 - transfer->hostname = g_string_new( gmyth_uri_gethost(transfer->uri) );
1.22 - transfer->port = gmyth_uri_getport( transfer->uri );
1.23 + transfer->hostname = g_string_new( gmyth_uri_get_host(transfer->uri) );
1.24 + transfer->port = gmyth_uri_get_port( transfer->uri );
1.25
1.26 g_debug ("[%s] URI: %s\n", __FUNCTION__, uri_str->str);
1.27 g_debug ("hostname: %s, port %d\n", transfer->hostname->str, transfer->port);
1.28 @@ -285,14 +287,15 @@
1.29 GString *resp = gmyth_socket_receive_response( transfer->event_sock );
1.30 g_print( "[%s] Got Monitor response from %s: %s\n", __FUNCTION__, base_str->str, resp->str );
1.31 //g_thread_create( (GThreadFunc)myth_control_sock_listener, transfer->event_sock->sd_io_ch, TRUE, NULL );
1.32 - //io_watcher_context = g_main_context_default();
1.33 + io_watcher_context = g_main_context_default();
1.34 GMainLoop *loop = g_main_loop_new( NULL, TRUE );
1.35
1.36 //GSource *source;
1.37
1.38 - if ( transfer->event_sock->sd_io_ch != NULL )
1.39 - source_id = g_io_add_watch( transfer->event_sock->sd_io_ch, G_IO_IN , (GIOFunc)myth_control_sock_listener, NULL );
1.40 - else {
1.41 + if ( transfer->event_sock->sd_io_ch != NULL ) {
1.42 + source_id = g_io_add_watch( transfer->event_sock->sd_io_ch, G_IO_IN, (GIOFunc)myth_control_sock_listener, NULL );
1.43 + //transfer->event_sock->sd_io_ch
1.44 + } else {
1.45 ret = FALSE;
1.46 goto cleanup;
1.47 }
1.48 @@ -334,7 +337,7 @@
1.49 g_return_val_if_fail (transfer->hostname != NULL, FALSE);
1.50 g_return_val_if_fail (transfer->port > 0, FALSE);
1.51
1.52 - gchar *path_dir = gmyth_uri_getpath (transfer->uri);
1.53 + gchar *path_dir = gmyth_uri_get_path (transfer->uri);
1.54
1.55 /* Creates the control socket */
1.56 transfer->control_sock = gmyth_socket_new();
1.57 @@ -496,6 +499,7 @@
1.58 {
1.59
1.60 gboolean ret = TRUE;
1.61 + guint max_iter = 50;
1.62
1.63 //g_mutex_lock( mutex );
1.64
1.65 @@ -506,15 +510,13 @@
1.66
1.67 //myth_control_acquire_context (FALSE);
1.68
1.69 - /*
1.70 g_mutex_lock( mutex );
1.71
1.72 if ( do_wait ) {
1.73 - if ( !g_main_context_wait( io_watcher_context, io_watcher_cond, mutex ) )
1.74 + while ( --max_iter > 0 && !g_main_context_wait( io_watcher_context, io_watcher_cond, mutex ) )
1.75 ret = FALSE;
1.76 } else if ( !g_main_context_acquire( io_watcher_context ) )
1.77 ret = FALSE;
1.78 - */
1.79
1.80 return ret;
1.81
1.82 @@ -526,9 +528,9 @@
1.83
1.84 gboolean ret = TRUE;
1.85
1.86 - //g_main_context_release( io_watcher_context );
1.87 + g_main_context_release( io_watcher_context );
1.88
1.89 - //g_mutex_unlock( mutex );
1.90 + g_mutex_unlock( mutex );
1.91
1.92 //has_io_access = TRUE;
1.93