[vlc-devel] patch modules/control/telnet.c (9649): fix race on close

Ted Deppner ted at psyber.com
Fri Dec 24 17:49:59 CET 2004


First off, great job on vlc and vlm in particular.  vlm rocks, and I'm
building internal use streaming servers around it for our company.  0.8.1
has been a huge leap in stability for vlm.

Attached is a patch to fix a race condition in vlm where the client closed
the connection, but didn't use the command "quit".  Typically this would
enter a race condition and consume 100% of cpu until vlm was killed.

It is likely there are a few other race conditions since there's no
checking of errno returns from the recv() call, but wanted to fire this
off as it meets my most pressing need at present.

I'm also interested in patches to VLM that would add a "stop at end of
playlist" (maybe control handle stopatend) and a percentage played status
option as well (control handle status?).  And of course a working playlist
in VLM again.  :)

Thanks.

-- 
Ted Deppner
http://www.deppner.us/
-------------- next part --------------
Index: modules/control/telnet.c
===================================================================
--- modules/control/telnet.c	(revision 9649)
+++ modules/control/telnet.c	(working copy)
@@ -278,8 +278,9 @@
             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 @@
                     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 );
+                }
             }
         }
 


More information about the vlc-devel mailing list