]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dbus: add -U,--dbus switch to manually enable the DBus interface
authorJaroslav Kysela <perex@perex.cz>
Mon, 18 Aug 2014 12:22:46 +0000 (14:22 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Aug 2014 12:22:46 +0000 (14:22 +0200)
src/dbus.c
src/dbus.h
src/main.c

index 4a8d09c7522ae9905de59fb1eea7faf08c1e9408..fd296434eeef69476c13bbf5d8f4c716fbe9e3e8 100644 (file)
@@ -439,22 +439,25 @@ dbus_server_thread(void *aux)
 pthread_t dbus_tid;
 
 void
-dbus_server_init(int session)
+dbus_server_init(int enabled, int session)
 {
   dbus_session = session;
   pthread_mutex_init(&dbus_lock, NULL);
   TAILQ_INIT(&dbus_signals);
   LIST_INIT(&dbus_rpcs);
-  tvh_pipe(O_NONBLOCK, &dbus_pipe);
-  dbus_threads_init_default();
-  dbus_running = 1;
-  dbus_emit_signal_str("/main", "start", tvheadend_version);
+  if (enabled) {
+    tvh_pipe(O_NONBLOCK, &dbus_pipe);
+    dbus_threads_init_default();
+    dbus_running = 1;
+    dbus_emit_signal_str("/main", "start", tvheadend_version);
+  }
 }
 
 void
 dbus_server_start(void)
 {
-  tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL);
+  if (dbus_pipe.wr > 0)
+    tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL);
 }
 
 void
@@ -464,9 +467,11 @@ dbus_server_done(void)
 
   dbus_emit_signal_str("/main", "stop", "bye");
   dbus_running = 0;
-  tvh_write(dbus_pipe.wr, "", 1);
-  pthread_kill(dbus_tid, SIGTERM);
-  pthread_join(dbus_tid, NULL);
+  if (dbus_pipe.wr > 0) {
+    tvh_write(dbus_pipe.wr, "", 1);
+    pthread_kill(dbus_tid, SIGTERM);
+    pthread_join(dbus_tid, NULL);
+  }
   dbus_flush_queue(NULL);
   while ((rpc = LIST_FIRST(&dbus_rpcs)) != NULL) {
     LIST_REMOVE(rpc, link);
index f3da5475459430b82bce48d13768db5667a63f44..2acd6c28252adc971026395559d92b509b268f5b 100644 (file)
@@ -39,7 +39,7 @@ void
 dbus_register_rpc_str(const char *call_name, void *opaque,
                       char *(*fcn)(void *, const char *, char *));
 
-void dbus_server_init(int session);
+void dbus_server_init(int enabled, int session);
 void dbus_server_start(void);
 void dbus_server_done(void);
 
@@ -60,7 +60,7 @@ static inline void
 dbus_register_rpc_str(const char *call_name, void *opaque,
                       char *(*fcn)(void *, const char *, char *)) { }
 
-static inline void dbus_server_init(int session) { }
+static inline void dbus_server_init(int enabled, int session) { }
 static inline void dbus_server_start(void) { }
 static inline void dbus_server_done(void) { }
 
index 3628ec8dfacdf5e69cc622f7eb0814b96c253e64..ea84a2d6ff4cf68cfe5d358c182a89085ef00a4d 100644 (file)
@@ -474,6 +474,7 @@ main(int argc, char **argv)
               opt_tsfile_tuner = 0,
               opt_dump         = 0,
               opt_xspf         = 0,
+              opt_dbus         = 0,
               opt_dbus_session = 0;
   const char *opt_config       = NULL,
              *opt_user         = NULL,
@@ -508,6 +509,8 @@ main(int argc, char **argv)
                              "the access-control from within the Tvheadend UI",
       OPT_BOOL, &opt_firstrun },
 #if ENABLE_DBUS_1
+    { 'U', "dbus",      "Enable DBus",
+      OPT_BOOL, &opt_dbus },
     { 'e', "dbus_session", "DBus - use the session message bus instead system one",
       OPT_BOOL, &opt_dbus_session },
 #endif
@@ -780,7 +783,7 @@ main(int argc, char **argv)
    * Initialize subsystems
    */
 
-  dbus_server_init(opt_dbus_session);
+  dbus_server_init(opt_dbus, opt_dbus_session);
 
   intlconv_init();