[svn r44] Some fixes. trunk
authorrosfran
Mon Oct 23 20:02:26 2006 +0100 (2006-10-23)
branchtrunk
changeset 43c9e53d7250f8
parent 42 9a5f5a33cd87
child 44 7a654d6de88f
[svn r44] Some fixes.
gmyth/src/gmyth_file_transfer.c
     1.1 --- a/gmyth/src/gmyth_file_transfer.c	Mon Oct 23 18:12:18 2006 +0100
     1.2 +++ b/gmyth/src/gmyth_file_transfer.c	Mon Oct 23 20:02:26 2006 +0100
     1.3 @@ -68,7 +68,7 @@
     1.4  static void gmyth_file_transfer_dispose  (GObject *object);
     1.5  static void gmyth_file_transfer_finalize (GObject *object);
     1.6  
     1.7 -static GMythSocket *myth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type );
     1.8 +static GMythSocket *gmyth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type );
     1.9  static void* myth_init_io_watchers( void *data );
    1.10  
    1.11  void gmyth_file_transfer_close( GMythFileTransfer *transfer );
    1.12 @@ -202,7 +202,7 @@
    1.13    /* configure the control socket */
    1.14    if ((*transfer)->control_sock == NULL) { 
    1.15  
    1.16 -    if ( myth_connect_to_transfer_backend ( transfer, GMYTH_PLAYBACK_TYPE ) == NULL ) {
    1.17 +    if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_PLAYBACK_TYPE ) == NULL ) {
    1.18        g_printerr( "Connection to backend failed (Control Socket).\n" );
    1.19        ret = FALSE;
    1.20      }
    1.21 @@ -230,7 +230,7 @@
    1.22    /* configure the control socket */
    1.23    if ((*transfer)->event_sock == NULL) { 
    1.24  
    1.25 -    if ( myth_connect_to_transfer_backend ( transfer, GMYTH_MONITOR_TYPE ) == NULL ) {
    1.26 +    if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_MONITOR_TYPE ) == NULL ) {
    1.27        g_printerr( "Connection to backend failed (Event Socket).\n" );
    1.28        ret = FALSE;
    1.29      }
    1.30 @@ -245,7 +245,7 @@
    1.31  
    1.32      //if ( live_tv == FALSE ) {
    1.33  
    1.34 -    if ( myth_connect_to_transfer_backend ( transfer, GMYTH_FILETRANSFER_TYPE ) == NULL ) {
    1.35 +    if ( gmyth_connect_to_transfer_backend ( transfer, GMYTH_FILETRANSFER_TYPE ) == NULL ) {
    1.36        g_printerr ("Connection to backend failed (Raw Transfer Socket).\n");
    1.37        ret = FALSE;
    1.38      }
    1.39 @@ -276,7 +276,7 @@
    1.40  }
    1.41  
    1.42  static GMythSocket *
    1.43 -myth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type )
    1.44 +gmyth_connect_to_transfer_backend( GMythFileTransfer **transfer, guint sock_type )
    1.45  {
    1.46    GMythSocket *sock = NULL;
    1.47  
    1.48 @@ -910,34 +910,44 @@
    1.49        gmyth_socket_read_stringlist( transfer->control_sock, strlist );
    1.50        if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) 
    1.51        {
    1.52 -      	sent = gmyth_string_list_get_int( strlist,  0 ); // -1 on backend error
    1.53 -      	g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent );
    1.54 -      	if ( sent != 0 )
    1.55 +      	GString *back_msg = NULL;
    1.56 +      	back_msg = gmyth_string_list_get_string( strlist, 0 );
    1.57 +      	if ( back_msg != NULL && back_msg->str != NULL && strstr( back_msg, "BACKEND" ) != NULL )
    1.58        	{
    1.59 -      		g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\
    1.60 -      			"io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, 
    1.61 -	  			recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" );
    1.62 -
    1.63 -	  		if ( sent == count_bytes )
    1.64 -	  		{
    1.65 -	  			response = ( recv == size ); 
    1.66 -	  			g_print( "[%s]\t\tsent %d, which is equals to bytes_read = %d\n\n", 
    1.67 -	  						__FUNCTION__, sent, count_bytes );
    1.68 -	  			if ( response == TRUE )
    1.69 -      				break;
    1.70 -	  		}
    1.71 -	  		else
    1.72 -	  		{
    1.73 -	  			g_print( "[%s]\t\tsent %d, which is NOT equals to bytes_read = %d\n\n", 
    1.74 -	  						__FUNCTION__, sent, count_bytes );
    1.75 -	  			goto cleanup;
    1.76 -	  			//response = FALSE;
    1.77 -	  			//break;
    1.78 -	  		}
    1.79 -      	} else {
    1.80 -      		break;
    1.81 -      		//goto cleanup;
    1.82 -      	} // if
    1.83 +      		recv = 0;
    1.84 +      		sent = 0;      		      	
    1.85 +      	} 
    1.86 +      	else 
    1.87 +      	{
    1.88 +	      	sent = gmyth_string_list_get_int( strlist,  0 ); // -1 on backend error
    1.89 +	      	g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent );
    1.90 +	      	if ( sent != 0 )
    1.91 +	      	{
    1.92 +	      		g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\
    1.93 +	      			"io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, 
    1.94 +		  			recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" );
    1.95 +	
    1.96 +		  		if ( sent == count_bytes )
    1.97 +		  		{
    1.98 +		  			response = ( recv == size ); 
    1.99 +		  			g_print( "[%s]\t\tsent %d, which is equals to bytes_read = %d\n\n", 
   1.100 +		  						__FUNCTION__, sent, count_bytes );
   1.101 +		  			if ( response == TRUE )
   1.102 +	      				break;
   1.103 +		  		}
   1.104 +		  		else
   1.105 +		  		{
   1.106 +		  			g_print( "[%s]\t\tsent %d, which is NOT equals to bytes_read = %d\n\n", 
   1.107 +		  						__FUNCTION__, sent, count_bytes );
   1.108 +		  			goto cleanup;
   1.109 +		  			//response = FALSE;
   1.110 +		  			//break;
   1.111 +		  		}
   1.112 +	      	} else {
   1.113 +	      		break;
   1.114 +	      		//goto cleanup;
   1.115 +	      	} // if
   1.116 +      	}
   1.117        } // if - reading control response from backend
   1.118      } else {
   1.119      	response = FALSE;
   1.120 @@ -949,7 +959,8 @@
   1.121   // io_cond = g_io_channel_get_buffer_condition( io_channel );
   1.122  
   1.123    if ( ( ( io_cond_control & G_IO_IN ) != 0 ) &&  		 
   1.124 -  		( response || ( recv == size ) ) )
   1.125 +  		//( response || ( recv == size ) ) )
   1.126 +  		( recv <= 0  || sent <= 0 )  )
   1.127    {
   1.128      if ( gmyth_socket_read_stringlist( transfer->control_sock, strlist ) > 0 )
   1.129      {