[dvblast-devel] dvblast can't bind unix local socket

Georgi Chorbadzhiyski gf at unixsol.org
Tue Aug 30 22:15:16 CEST 2011


On 8/30/11 9:57 PM, Eduardo Vieira wrote:
> I'm experimenting a strange behavior in dvblast. When I open it, close
> and then open again with the -r option the following message is
> printed:
> error: cannot bind comm socket (Address already in use)
>
> I guess it's because when I close a dvblast instance that was runned
> with the -r option, it leaves the socket file (should it be removed
> before closing ?). So, when the new instance is lauched, the bind
> don't works.
>
> Is this a bug or a normal expected behavior ?

Definitely a bug :) Please apply the attached 2 patches I think they'll
solve the problem nicely.

-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
-------------- next part --------------
>From 7dd0113f1c49a2e1766a8cef6b992c7fbf5a539b Mon Sep 17 00:00:00 2001
From: Georgi Chorbadzhiyski <gf at unixsol.org>
Date: Wed, 24 Aug 2011 19:52:52 +0300
Subject: [PATCH 1/2] Install SIGINT handler to be able to break out of main
 loop.

---
 dvblast.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dvblast.c b/dvblast.c
index 7cd6c7e..3e35f3d 100644
--- a/dvblast.c
+++ b/dvblast.c
@@ -95,6 +95,7 @@ const char *psz_dvb_charset = "ISO_8859-1";
 print_type_t i_print_type = -1;
 
 volatile sig_atomic_t b_hup_received = 0;
+volatile sig_atomic_t b_exit_now = 0;
 int i_verbose = DEFAULT_VERBOSITY;
 int i_syslog = 0;
 
@@ -388,7 +389,10 @@ static void config_ReadFile( char *psz_file )
  *****************************************************************************/
 static void SigHandler( int i_signal )
 {
-    b_hup_received = 1;
+    if ( i_signal == SIGHUP )
+        b_hup_received = 1;
+    if ( i_signal == SIGINT )
+        b_exit_now = 1;
 }
 
 /*****************************************************************************
@@ -896,7 +900,7 @@ int main( int i_argc, char **pp_argv )
     sa.sa_handler = SigHandler;
     sigfillset( &set );
 
-    if ( sigaction( SIGHUP, &sa, NULL ) == -1 )
+    if ( sigaction( SIGHUP, &sa, NULL ) == -1 || sigaction( SIGINT, &sa, NULL ) == -1 )
     {
         msg_Err( NULL, "couldn't set signal handler: %s", strerror(errno) );
         exit(EXIT_FAILURE);
@@ -930,6 +934,12 @@ int main( int i_argc, char **pp_argv )
     {
         block_t *p_ts;
 
+        if ( b_exit_now )
+        {
+            msg_Info( NULL, "Shutdown was requested." );
+            break;
+        }
+
         if ( b_hup_received )
         {
             b_hup_received = 0;
-- 
1.7.5.1

-------------- next part --------------
>From 6a8a12e18e5572aa9b285fc2f2f52b2e857db076 Mon Sep 17 00:00:00 2001
From: Georgi Chorbadzhiyski <gf at unixsol.org>
Date: Tue, 30 Aug 2011 23:06:41 +0300
Subject: [PATCH 2/2] dvblast: Remove comm socket on exit.

---
 dvblast.c |    4 ++++
 dvblast.h |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dvblast.c b/dvblast.c
index 3e35f3d..1125afb 100644
--- a/dvblast.c
+++ b/dvblast.c
@@ -974,5 +974,9 @@ int main( int i_argc, char **pp_argv )
     mrtgClose();
     if ( b_enable_syslog )
         msg_Disconnect();
+
+    if ( psz_srv_socket && i_comm_fd > -1 )
+        unlink( psz_srv_socket );
+
     return EXIT_SUCCESS;
 }
diff --git a/dvblast.h b/dvblast.h
index f343873..5265e82 100644
--- a/dvblast.h
+++ b/dvblast.h
@@ -137,6 +137,7 @@ extern output_t **pp_outputs;
 extern int i_nb_outputs;
 extern output_t output_dup;
 extern char *psz_srv_socket;
+extern int i_comm_fd;
 extern int i_adapter;
 extern int i_fenum;
 extern int i_frequency;
-- 
1.7.5.1



More information about the dvblast-devel mailing list