]> git.sesse.net Git - vlc/commitdiff
- Fix file descriptors leak
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 15 Feb 2007 17:08:22 +0000 (17:08 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 15 Feb 2007 17:08:22 +0000 (17:08 +0000)
- Use net_Read() instead of net_ReadNonBlock()

modules/control/rc.c

index 70e3cd830cf912cc68b0a1bfe3fb47dcf98cf8fd..3428849ca3086969aa283753d9d1e84115c4fa2c 100644 (file)
@@ -2020,9 +2020,9 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
 #endif
 
     while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH &&
-           (i_read = net_ReadNonBlock( p_intf, p_intf->p_sys->i_socket == -1 ?
+           (i_read = net_Read( p_intf, p_intf->p_sys->i_socket == -1 ?
                        0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket, NULL,
-                  (uint8_t *)p_buffer + *pi_size, 1, INTF_IDLE_SLEEP ) ) > 0 )
+                  (uint8_t *)p_buffer + *pi_size, 1, VLC_FALSE ) ) > 0 )
     {
         if( p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' )
             break;
@@ -2031,9 +2031,17 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
     }
 
     /* Connection closed */
-    if( i_read == -1 )
+    if( i_read <= 0 )
     {
-        p_intf->p_sys->i_socket = -1;
+        if( p_intf->p_sys->i_socket != -1 )
+        {
+            net_Close( p_intf->p_sys->i_socket );
+            p_intf->p_sys->i_socket = -1;
+        }
+        else
+            /* Standard input closed: exit */
+            p_intf->b_die = VLC_TRUE;
+
         p_buffer[ *pi_size ] = 0;
         return VLC_TRUE;
     }