]> git.sesse.net Git - vlc/commitdiff
Fix connection close, patch by Ted Deppner <ted at psyber dot com>
authorClément Stenac <zorglub@videolan.org>
Sat, 25 Dec 2004 12:21:47 +0000 (12:21 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 25 Dec 2004 12:21:47 +0000 (12:21 +0000)
modules/control/telnet.c

index e7a3cecd1ceea1d2c7c9e9c3dda0bcc435878133..00b41b378e1be699513bdb3505e55bc21576f6e2 100644 (file)
@@ -278,8 +278,9 @@ static void Run( intf_thread_t *p_intf )
             else if( FD_ISSET( cl->fd, &fds_read) )
             {
                 int i_end = 0;
+                int i_recv;
 
-                while( recv( cl->fd, cl->p_buffer_read, 1, 0 ) > 0 &&
+                while( (i_recv=recv( cl->fd, cl->p_buffer_read, 1, 0 )) > 0 &&
                        cl->p_buffer_read - cl->buffer_read < 999 )
                 {
                     switch( cl->i_tel_cmd )
@@ -330,6 +331,14 @@ static void Run( intf_thread_t *p_intf )
                     Write_message( cl, NULL, "Line too long\r\n",
                                    cl->i_mode + 2 );
                 }
+
+                if (i_recv == 0)
+                {
+                    net_Close( cl->fd );
+                    TAB_REMOVE( p_intf->p_sys->i_clients ,
+                                p_intf->p_sys->clients , cl );
+                    free( cl );
+                }
             }
         }