]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Ensure the metadata pipe is created, if necessary, when the --with-metadata option...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 11 Sep 2020 15:54:34 +0000 (16:54 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 11 Sep 2020 15:54:34 +0000 (16:54 +0100)
common.c
configure.ac
rtsp.c

index c1deea32441f36120a7adfed601e7d52032c3640..cdd4d03115f05bddd87cedacd2d98097d307b3e9 100644 (file)
--- a/common.c
+++ b/common.c
@@ -170,15 +170,18 @@ int create_log_file(const char *path) {
             int flags = fcntl(fd, F_GETFL);
             if (flags == -1) {
               //                                                       strerror_r(errno, (char
-              //*)errorstring, sizeof(errorstring));                                                   debug(1, "create_log_file -- error %d (\"%s\")
-              //getting flags of pipe: \"%s\".", errno,                                                                                (char *)errorstring, pathname);
+              //*)errorstring, sizeof(errorstring));
+              //debug(1, "create_log_file -- error %d (\"%s\") getting flags of pipe: \"%s\".",
+              // errno,
+              // (char *)errorstring, pathname);
             } else {
               flags = fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
               //                                                       if (flags == -1) {
               //                                                               strerror_r(errno,
-              //(char *)errorstring, sizeof(errorstring));                                                             debug(1, "create_log_file -- error %d
-              //(\"%s\") unsetting NONBLOCK of pipe: \"%s\".", errno,                                                                                  (char *)errorstring,
-              //pathname);
+              //(char *)errorstring, sizeof(errorstring));
+              //debug(1, "create_log_file -- error %d
+              //(\"%s\") unsetting NONBLOCK of pipe: \"%s\".", errno,
+              //(char *)errorstring, pathname);
             }
           }
         }
index 81b62972d47c5574827cf7b0dce8affdf7afe7b0..97fc87d1b3572f725187a16d3aa3b44a8faf7e51 100644 (file)
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.50])
-AC_INIT([shairport-sync], [3.3.7d18], [4265913+mikebrady@users.noreply.github.com])
+AC_INIT([shairport-sync], [3.3.7d19], [4265913+mikebrady@users.noreply.github.com])
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([shairport.c])
 AC_CONFIG_HEADERS([config.h])
diff --git a/rtsp.c b/rtsp.c
index af9e970675fb4b6b9f9d6611a6b5b55cd81fda21..a1eeff13d4b62e5f1037b90d3db519adc01b1af3 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -1320,7 +1320,6 @@ void metadata_create_multicast_socket(void) {
     } else {
       int buffer_size = METADATA_SNDBUF;
       setsockopt(metadata_sock, SOL_SOCKET, SO_SNDBUF, &buffer_size, sizeof(buffer_size));
-      fcntl(fd, F_SETFL, O_NONBLOCK);
       bzero((char *)&metadata_sockaddr, sizeof(metadata_sockaddr));
       metadata_sockaddr.sin_family = AF_INET;
       metadata_sockaddr.sin_addr.s_addr = inet_addr(config.metadata_sockaddr);
@@ -1584,32 +1583,6 @@ void metadata_hub_thread_cleanup_function(__attribute__((unused)) void *arg) {
 
 void *metadata_hub_thread_function(__attribute__((unused)) void *ignore) {
 
-  // create the fifo, if necessary
-  size_t pl = strlen(config.metadata_pipename) + 1;
-  char *path = malloc(pl + 1);
-  snprintf(path, pl + 1, "%s", config.metadata_pipename);
-
-  mode_t oldumask = umask(000);
-  if (mkfifo(path, 0666) && errno != EEXIST)
-    die("Could not create metadata pipe \"%s\".", path);
-  umask(oldumask);
-  debug(1, "metadata pipe name is \"%s\".", path);
-
-  // try to open it
-  fd = try_to_open_pipe_for_writing(path);
-  // we check that it's not a "real" error. From the "man 2 open" page:
-  // "ENXIO  O_NONBLOCK | O_WRONLY is set, the named file is a FIFO, and no process has the FIFO
-  // open for reading." Which is okay.
-  if ((fd == -1) && (errno != ENXIO)) {
-    char errorstring[1024];
-    strerror_r(errno, (char *)errorstring, sizeof(errorstring));
-    debug(1, "metadata_hub_thread_function -- error %d (\"%s\") opening pipe: \"%s\".", errno,
-          (char *)errorstring, path);
-    warn("can not open metadata pipe -- error %d (\"%s\") opening pipe: \"%s\".", errno,
-         (char *)errorstring, path);
-  }
-  free(path);
-
   // create a pc_queue for passing information to a threaded metadata handler
   pc_queue_init(&metadata_hub_queue, (char *)&metadata_hub_queue_items, sizeof(metadata_package),
                 metadata_hub_queue_size, "hub");
@@ -1675,6 +1648,33 @@ void *metadata_mqtt_thread_function(__attribute__((unused)) void *ignore) {
 #endif
 
 void metadata_init(void) {
+
+  // create the metadata pipe, if necessary
+  size_t pl = strlen(config.metadata_pipename) + 1;
+  char *path = malloc(pl + 1);
+  snprintf(path, pl + 1, "%s", config.metadata_pipename);
+
+  mode_t oldumask = umask(000);
+  if (mkfifo(path, 0666) && errno != EEXIST)
+    die("Could not create metadata pipe \"%s\".", path);
+  umask(oldumask);
+  debug(1, "metadata pipe name is \"%s\".", path);
+
+  // try to open it
+  fd = try_to_open_pipe_for_writing(path);
+  // we check that it's not a "real" error. From the "man 2 open" page:
+  // "ENXIO  O_NONBLOCK | O_WRONLY is set, the named file is a FIFO, and no process has the FIFO
+  // open for reading." Which is okay.
+  if ((fd == -1) && (errno != ENXIO)) {
+    char errorstring[1024];
+    strerror_r(errno, (char *)errorstring, sizeof(errorstring));
+    debug(1, "metadata_hub_thread_function -- error %d (\"%s\") opening pipe: \"%s\".", errno,
+          (char *)errorstring, path);
+    warn("can not open metadata pipe -- error %d (\"%s\") opening pipe: \"%s\".", errno,
+         (char *)errorstring, path);
+  }
+  free(path);
+
   int ret = pthread_create(&metadata_thread, NULL, metadata_thread_function, NULL);
   if (ret)
     debug(1, "Failed to create metadata thread!");