# HG changeset patch # User rosfran # Date 1171291965 0 # Node ID f3b8627a51e45a9ec3941f388dfec5aaf0fe2246 # Parent d803a518d7ca29d1ccffa7c59d3577f0a035e863 [svn r355] Added G_IO_IN event handlers, using g_io_add_watch, to the GMyth's MonitorHandler. diff -r d803a518d7ca -r f3b8627a51e4 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Mon Feb 12 13:31:29 2007 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Mon Feb 12 14:52:45 2007 +0000 @@ -558,13 +558,11 @@ io_cond_control = g_io_channel_get_buffer_condition( io_channel ); if ( transfer->sock == NULL || ( io_status == G_IO_STATUS_ERROR ) ) { g_printerr( "gmyth_file_transfer_read(): Called with no raw socket.\n" ); - //exit(0); // fixme remove this return -1; } if ( transfer->control_sock == NULL || ( io_status_control == G_IO_STATUS_ERROR ) ) { g_printerr( "gmyth_file_transfer_read(): Called with no control socket.\n" ); - //exit(0); // fixme remove this return -1; } @@ -619,9 +617,12 @@ strlist = NULL; break; } - g_object_unref (strlist); - strlist = NULL; - } + if ( strlist!=NULL ) + { + g_object_unref (strlist); + strlist = NULL; + } + } /* while - iterates through bytes until reaches the end of stream */ if ( bytes_sent == 0 && max_tries == 0 ) { diff -r d803a518d7ca -r f3b8627a51e4 gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Mon Feb 12 13:31:29 2007 +0000 +++ b/gmyth/src/gmyth_monitor_handler.c Mon Feb 12 14:52:45 2007 +0000 @@ -425,13 +425,13 @@ myth_control_acquire_context (monitor, TRUE); - if ( io_channel == NULL ) { + if ( NULL == io_channel ) { g_debug ("Monitor socket is NULL!\n"); *ret = FALSE; goto clean_up; } - while (monitor->allow_msgs_listener) { + if (monitor->allow_msgs_listener) { ++count; gmyth_debug ("%d - Listening on Monitor socket...!\n", count); @@ -448,7 +448,7 @@ len = gmyth_socket_read_stringlist( monitor->event_sock, strlist ); - if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) + if ( ( len > 0 ) && strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) { bytes_sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error @@ -465,10 +465,10 @@ &back_msg_action ); if (monitor!=NULL) - g_signal_emit ( monitor, - GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id, - 0, /* details */ - msg_type, back_msg_action ); + g_signal_emit ( monitor, + GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id, + 0, /* details */ + msg_type, back_msg_action ); if (back_msg_action!= NULL) g_free( back_msg_action ); @@ -478,13 +478,16 @@ } if (strlist!=NULL) + { g_object_unref( strlist ); + strlist = NULL; + } io_cond = g_io_channel_get_buffer_condition( io_channel ); - } while ( recv <= 0 && ( io_cond & G_IO_IN ) != 0 ); + } while ( recv <= 0 /* && ( io_cond & G_IO_IN ) != 0 */); - gmyth_debug ("[%s]\tMONITOR EVENT: Read %d bytes\n", __FUNCTION__, recv ); + gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv ); g_usleep( 300 ); @@ -500,9 +503,6 @@ } clean_up: - - if (strlist!=NULL) - g_object_unref( strlist ); return *ret; @@ -542,7 +542,7 @@ if ( channel != NULL ) { //source = g_io_create_watch( channel, G_IO_IN | G_IO_HUP ); - src_id = g_io_add_watch( channel, G_IO_IN, + src_id = g_io_add_watch( channel, G_IO_IN | G_IO_HUP, (GIOFunc)gmyth_monitor_handler_listener, monitor ); } else { *ret = FALSE; @@ -596,7 +596,8 @@ */ //if ( ( ret = g_thread_join( monitor_th ) ) == FALSE ) //if ( monitor->monitor_th != NULL ) - if ( gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch ) ) + ret = gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch ); + if ( *ret ) { gmyth_debug ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n", __FUNCTION__, g_thread_self( ) ); diff -r d803a518d7ca -r f3b8627a51e4 gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Mon Feb 12 13:31:29 2007 +0000 +++ b/gmyth/src/gmyth_socket.c Mon Feb 12 14:52:45 2007 +0000 @@ -565,16 +565,14 @@ gmyth_socket->sd_io_ch = g_io_channel_unix_new (gmyth_socket->sd); g_io_channel_set_close_on_unref (gmyth_socket->sd_io_ch, TRUE); - g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL ); + //g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL ); - #if 0 GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch); /* unset the nonblock flag */ flags &= ~G_IO_FLAG_NONBLOCK; /* unset the nonblocking stuff for some time, because GNUTLS doesn't like * that */ g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL); - #endif ret = ( ret_code == 0 ) ? TRUE : FALSE ; if ( !ret )