#define UNIX_LONGTEXT N_("Accept commands over a Unix socket rather than " \
"stdin." )
+#define OVERWRITE_TEXT N_("Over-write UNIX socket")
+#define OVERWRITE_LONGTEXT N_("If unable to bind RC interface to the specified " \
+ " UNIX socket will attempt to unlink it then retry." )
+
#define HOST_TEXT N_("TCP command input")
#define HOST_LONGTEXT N_("Accept commands over a socket rather than stdin. " \
"You can set the address and port the interface will bind to." )
#endif
add_string( "rc-unix", 0, NULL, UNIX_TEXT, UNIX_LONGTEXT, VLC_TRUE );
add_string( "rc-host", 0, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
+ add_bool( "rc-overwrite", 0, NULL, OVERWRITE_TEXT, OVERWRITE_LONGTEXT, VLC_TRUE );
#ifdef WIN32
add_bool( "rc-quiet", 0, NULL, QUIET_TEXT, QUIET_LONGTEXT, VLC_FALSE );
psz_unix_path = config_GetPsz( p_intf, "rc-unix" );
if( psz_unix_path )
{
- int i_socket;
+ int i_socket, i_overwrite;
+
+ i_overwrite = config_GetInt( p_intf, "rc-overwrite" );
+
#if !defined(AF_LOCAL) || defined(WIN32)
msg_Warn( p_intf, "your OS doesn't support filesystem sockets" );
if( (i_ret = bind( i_socket, (struct sockaddr*)&addr,
sizeof(struct sockaddr_un) ) ) < 0 )
{
- msg_Warn( p_intf, "couldn't bind socket to address: %s",
- strerror(errno) );
- free( psz_unix_path );
- net_Close( i_socket );
- return VLC_EGENERIC;
+ if( i_overwrite )
+ {
+ msg_Warn( p_intf, "Found old UNIX socket: %s, deleting and re-trying", psz_unix_path );
+ unlink( psz_unix_path );
+ }
+
+ if( !i_overwrite || bind( i_socket, (struct sockaddr*)&addr,
+ sizeof(struct sockaddr_un) ) < 0 )
+ {
+
+ msg_Warn( p_intf, "couldn't bind socket to address: %s",
+ strerror(errno) );
+ free( psz_unix_path );
+ net_Close( i_socket );
+ return VLC_EGENERIC;
+ }
}
if( ( i_ret = listen( i_socket, 1 ) ) < 0 )