# HG changeset patch # User rosfran # Date 1161630146 -3600 # Node ID c9e53d7250f821e4780e47d5c7de75465604f3b1 # Parent 9a5f5a33cd87e98e61234ef54461a6f145d43b1d [svn r44] Some fixes. diff -r 9a5f5a33cd87 -r c9e53d7250f8 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Mon Oct 23 18:12:18 2006 +0100 +++ b/gmyth/src/gmyth_file_transfer.c Mon Oct 23 20:02:26 2006 +0100 @@ -68,7 +68,7 @@ static void gmyth_file_transfer_dispose (GObject *object); static void gmyth_file_transfer_finalize (GObject *object); -static GMythSocket *myth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type ); +static GMythSocket *gmyth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type ); static void* myth_init_io_watchers( void *data ); void gmyth_file_transfer_close( GMythFileTransfer *transfer ); @@ -202,7 +202,7 @@ /* configure the control socket */ if ((*transfer)->control_sock == NULL) { - if ( myth_connect_to_transfer_backend ( transfer, GMYTH_PLAYBACK_TYPE ) == NULL ) { + if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_PLAYBACK_TYPE ) == NULL ) { g_printerr( "Connection to backend failed (Control Socket).\n" ); ret = FALSE; } @@ -230,7 +230,7 @@ /* configure the control socket */ if ((*transfer)->event_sock == NULL) { - if ( myth_connect_to_transfer_backend ( transfer, GMYTH_MONITOR_TYPE ) == NULL ) { + if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_MONITOR_TYPE ) == NULL ) { g_printerr( "Connection to backend failed (Event Socket).\n" ); ret = FALSE; } @@ -245,7 +245,7 @@ //if ( live_tv == FALSE ) { - if ( myth_connect_to_transfer_backend ( transfer, GMYTH_FILETRANSFER_TYPE ) == NULL ) { + if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_FILETRANSFER_TYPE ) == NULL ) { g_printerr ("Connection to backend failed (Raw Transfer Socket).\n"); ret = FALSE; } @@ -276,7 +276,7 @@ } static GMythSocket * -myth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type ) +gmyth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type ) { GMythSocket *sock = NULL; @@ -910,34 +910,44 @@ gmyth_socket_read_stringlist( transfer->control_sock, strlist ); if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) { - sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error - g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent ); - if ( sent != 0 ) + GString *back_msg = NULL; + back_msg = gmyth_string_list_get_string( strlist, 0 ); + if ( back_msg != NULL && back_msg->str != NULL && strstr( back_msg, "BACKEND" ) != NULL ) { - g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\ - "io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, - recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); - - if ( sent == count_bytes ) - { - response = ( recv == size ); - g_print( "[%s]\t\tsent %d, which is equals to bytes_read = %d\n\n", - __FUNCTION__, sent, count_bytes ); - if ( response == TRUE ) - break; - } - else - { - g_print( "[%s]\t\tsent %d, which is NOT equals to bytes_read = %d\n\n", - __FUNCTION__, sent, count_bytes ); - goto cleanup; - //response = FALSE; - //break; - } - } else { - break; - //goto cleanup; - } // if + recv = 0; + sent = 0; + } + else + { + sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error + g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent ); + if ( sent != 0 ) + { + g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\ + "io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, + recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); + + if ( sent == count_bytes ) + { + response = ( recv == size ); + g_print( "[%s]\t\tsent %d, which is equals to bytes_read = %d\n\n", + __FUNCTION__, sent, count_bytes ); + if ( response == TRUE ) + break; + } + else + { + g_print( "[%s]\t\tsent %d, which is NOT equals to bytes_read = %d\n\n", + __FUNCTION__, sent, count_bytes ); + goto cleanup; + //response = FALSE; + //break; + } + } else { + break; + //goto cleanup; + } // if + } } // if - reading control response from backend } else { response = FALSE; @@ -949,7 +959,8 @@ // io_cond = g_io_channel_get_buffer_condition( io_channel ); if ( ( ( io_cond_control & G_IO_IN ) != 0 ) && - ( response || ( recv == size ) ) ) + //( response || ( recv == size ) ) ) + ( recv <= 0 || sent <= 0 ) ) { if ( gmyth_socket_read_stringlist( transfer->control_sock, strlist ) > 0 ) {