[svn r355] Added G_IO_IN event handlers, using g_io_add_watch, to the GMyth's MonitorHandler.
1.1 --- a/gmyth/src/gmyth_file_transfer.c Mon Feb 12 13:31:29 2007 +0000
1.2 +++ b/gmyth/src/gmyth_file_transfer.c Mon Feb 12 14:52:45 2007 +0000
1.3 @@ -558,13 +558,11 @@
1.4 io_cond_control = g_io_channel_get_buffer_condition( io_channel );
1.5 if ( transfer->sock == NULL || ( io_status == G_IO_STATUS_ERROR ) ) {
1.6 g_printerr( "gmyth_file_transfer_read(): Called with no raw socket.\n" );
1.7 - //exit(0); // fixme remove this
1.8 return -1;
1.9 }
1.10
1.11 if ( transfer->control_sock == NULL || ( io_status_control == G_IO_STATUS_ERROR ) ) {
1.12 g_printerr( "gmyth_file_transfer_read(): Called with no control socket.\n" );
1.13 - //exit(0); // fixme remove this
1.14 return -1;
1.15 }
1.16
1.17 @@ -619,9 +617,12 @@
1.18 strlist = NULL;
1.19 break;
1.20 }
1.21 - g_object_unref (strlist);
1.22 - strlist = NULL;
1.23 - }
1.24 + if ( strlist!=NULL )
1.25 + {
1.26 + g_object_unref (strlist);
1.27 + strlist = NULL;
1.28 + }
1.29 + } /* while - iterates through bytes until reaches the end of stream */
1.30
1.31 if ( bytes_sent == 0 && max_tries == 0 )
1.32 {
2.1 --- a/gmyth/src/gmyth_monitor_handler.c Mon Feb 12 13:31:29 2007 +0000
2.2 +++ b/gmyth/src/gmyth_monitor_handler.c Mon Feb 12 14:52:45 2007 +0000
2.3 @@ -425,13 +425,13 @@
2.4
2.5 myth_control_acquire_context (monitor, TRUE);
2.6
2.7 - if ( io_channel == NULL ) {
2.8 + if ( NULL == io_channel ) {
2.9 g_debug ("Monitor socket is NULL!\n");
2.10 *ret = FALSE;
2.11 goto clean_up;
2.12 }
2.13
2.14 - while (monitor->allow_msgs_listener) {
2.15 + if (monitor->allow_msgs_listener) {
2.16 ++count;
2.17
2.18 gmyth_debug ("%d - Listening on Monitor socket...!\n", count);
2.19 @@ -448,7 +448,7 @@
2.20
2.21 len = gmyth_socket_read_stringlist( monitor->event_sock, strlist );
2.22
2.23 - if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 )
2.24 + if ( ( len > 0 ) && strlist != NULL && gmyth_string_list_length( strlist ) > 0 )
2.25 {
2.26 bytes_sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error
2.27
2.28 @@ -465,10 +465,10 @@
2.29 &back_msg_action );
2.30
2.31 if (monitor!=NULL)
2.32 - g_signal_emit ( monitor,
2.33 - GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id,
2.34 - 0, /* details */
2.35 - msg_type, back_msg_action );
2.36 + g_signal_emit ( monitor,
2.37 + GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id,
2.38 + 0, /* details */
2.39 + msg_type, back_msg_action );
2.40
2.41 if (back_msg_action!= NULL)
2.42 g_free( back_msg_action );
2.43 @@ -478,13 +478,16 @@
2.44 }
2.45
2.46 if (strlist!=NULL)
2.47 + {
2.48 g_object_unref( strlist );
2.49 + strlist = NULL;
2.50 + }
2.51
2.52 io_cond = g_io_channel_get_buffer_condition( io_channel );
2.53
2.54 - } while ( recv <= 0 && ( io_cond & G_IO_IN ) != 0 );
2.55 + } while ( recv <= 0 /* && ( io_cond & G_IO_IN ) != 0 */);
2.56
2.57 - gmyth_debug ("[%s]\tMONITOR EVENT: Read %d bytes\n", __FUNCTION__, recv );
2.58 + gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv );
2.59
2.60 g_usleep( 300 );
2.61
2.62 @@ -500,9 +503,6 @@
2.63 }
2.64
2.65 clean_up:
2.66 -
2.67 - if (strlist!=NULL)
2.68 - g_object_unref( strlist );
2.69
2.70 return *ret;
2.71
2.72 @@ -542,7 +542,7 @@
2.73
2.74 if ( channel != NULL ) {
2.75 //source = g_io_create_watch( channel, G_IO_IN | G_IO_HUP );
2.76 - src_id = g_io_add_watch( channel, G_IO_IN,
2.77 + src_id = g_io_add_watch( channel, G_IO_IN | G_IO_HUP,
2.78 (GIOFunc)gmyth_monitor_handler_listener, monitor );
2.79 } else {
2.80 *ret = FALSE;
2.81 @@ -596,7 +596,8 @@
2.82 */
2.83 //if ( ( ret = g_thread_join( monitor_th ) ) == FALSE )
2.84 //if ( monitor->monitor_th != NULL )
2.85 - if ( gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch ) )
2.86 + ret = gmyth_monitor_handler_setup( monitor, monitor->event_sock->sd_io_ch );
2.87 + if ( *ret )
2.88 {
2.89 gmyth_debug ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n",
2.90 __FUNCTION__, g_thread_self( ) );
3.1 --- a/gmyth/src/gmyth_socket.c Mon Feb 12 13:31:29 2007 +0000
3.2 +++ b/gmyth/src/gmyth_socket.c Mon Feb 12 14:52:45 2007 +0000
3.3 @@ -565,16 +565,14 @@
3.4 gmyth_socket->sd_io_ch = g_io_channel_unix_new (gmyth_socket->sd);
3.5
3.6 g_io_channel_set_close_on_unref (gmyth_socket->sd_io_ch, TRUE);
3.7 - g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL );
3.8 + //g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL );
3.9
3.10 - #if 0
3.11 GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch);
3.12 /* unset the nonblock flag */
3.13 flags &= ~G_IO_FLAG_NONBLOCK;
3.14 /* unset the nonblocking stuff for some time, because GNUTLS doesn't like
3.15 * that */
3.16 g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL);
3.17 - #endif
3.18
3.19 ret = ( ret_code == 0 ) ? TRUE : FALSE ;
3.20 if ( !ret )