Commit fa22abdc authored by Felix Paul Kühne's avatar Felix Paul Kühne

retry on failure to connect to rc-unix socket. Patch by Greg Farrell (greg a ...

retry on failure to connect to rc-unix socket. Patch by Greg Farrell (greg  a  lincor.com), submitted by Dermot McGahon (dermot  a  dspsrv.com)
parent 6382b7d9
......@@ -167,6 +167,10 @@ void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
#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." )
......@@ -191,6 +195,7 @@ vlc_module_begin();
#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 );
......@@ -221,7 +226,10 @@ static int Activate( vlc_object_t *p_this )
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" );
......@@ -249,11 +257,22 @@ static int Activate( vlc_object_t *p_this )
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 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment