]> git.sesse.net Git - vlc/blobdiff - modules/control/telnet.c
cdda/info: fix memleaks.
[vlc] / modules / control / telnet.c
index 6f1c2dc0359e1c8a27ff2a1f4b5836e45166f083..e7bb2e19c9d60fd35d1c61b92dbf5e718f3bfbda 100644 (file)
  * Preamble
  *****************************************************************************/
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_interface.h>
 #include <vlc_input.h>
 
@@ -43,7 +48,7 @@
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
-#ifdef HAVE_POLL_H
+#ifdef HAVE_POLL
 #   include <poll.h>
 #endif
 
@@ -89,13 +94,13 @@ vlc_module_begin();
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_CONTROL );
     add_string( "telnet-host", "", NULL, TELNETHOST_TEXT,
-                 TELNETHOST_LONGTEXT, VLC_TRUE );
+                 TELNETHOST_LONGTEXT, true );
     add_integer( "telnet-port", TELNETPORT_DEFAULT, NULL, TELNETPORT_TEXT,
-                 TELNETPORT_LONGTEXT, VLC_TRUE );
+                 TELNETPORT_LONGTEXT, true );
     add_password( "telnet-password", TELNETPWD_DEFAULT, NULL, TELNETPWD_TEXT,
-                TELNETPWD_LONGTEXT, VLC_TRUE );
-    set_description( _("VLM remote control interface") );
-    add_category_hint( "VLM", NULL, VLC_FALSE );
+                TELNETPWD_LONGTEXT, true );
+    set_description( N_("VLM remote control interface") );
+    add_category_hint( "VLM", NULL, false );
     set_capability( "interface", 0 );
     set_callbacks( Open , Close );
 vlc_module_end();
@@ -226,7 +231,7 @@ static void Close( vlc_object_t *p_this )
         free( cl );
         p_sys->clients[i] = NULL;
     }
-    if( p_sys->clients != NULL ) free( p_sys->clients );
+    free( p_sys->clients );
 
     net_ListenClose( p_sys->pi_fd );
 
@@ -371,7 +376,7 @@ static void Run( intf_thread_t *p_intf )
                                    cl->i_mode + 2 );
                 }
 
-                if (i_recv <= 0)
+                if (i_recv <= 0 && ( end || errno != EAGAIN ) )
                     goto drop;
             }
         }
@@ -490,7 +495,7 @@ static void Run( intf_thread_t *p_intf )
             if (ufd[ncli + i].revents == 0)
                 continue;
 
-            fd = accept (ufd[ncli + i].fd, NULL, NULL);
+            fd = net_AcceptSingle (VLC_OBJECT(p_intf), ufd[ncli + i].fd);
             if (fd == -1)
                 continue;
 
@@ -511,8 +516,7 @@ static void Run( intf_thread_t *p_intf )
             TAB_APPEND( p_sys->i_clients, p_sys->clients, cl );
         }
     }
-    if( psz_password )
-        free( psz_password );
+    free( psz_password );
 }
 
 static void Write_message( telnet_client_t *client, vlm_message_t *message,
@@ -522,7 +526,7 @@ static void Write_message( telnet_client_t *client, vlm_message_t *message,
 
     client->p_buffer_read = client->buffer_read;
     (client->p_buffer_read)[0] = 0; // if (cl->p_buffer_read)[0] = '\n'
-    if( client->buffer_write ) free( client->buffer_write );
+    free( client->buffer_write );
 
     /* generate the psz_message string */
     if( message )