Replace wrong implementation of log to file in pa_daemon_conf_set_log_level to 
pa_daemon_conf_set_log_target

Signed-off-by: Vincent Becker <vincentx.bec...@intel.com>
---
 src/daemon/daemon-conf.c |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 0d42f73..35935f9 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -142,8 +142,6 @@ static const pa_daemon_conf default_conf = {
 #endif
 };
 
-static int log_fd = -1;
-
 pa_daemon_conf* pa_daemon_conf_new(void) {
     pa_daemon_conf *c;
 
@@ -170,8 +168,7 @@ pa_daemon_conf* pa_daemon_conf_new(void) {
 void pa_daemon_conf_free(pa_daemon_conf *c) {
     pa_assert(c);
 
-    if (log_fd >= 0)
-        pa_close(log_fd);
+    pa_log_set_fd(-1);
 
     pa_xfree(c->script_commands);
     pa_xfree(c->dl_search_path);
@@ -192,7 +189,24 @@ int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const 
char *string) {
     } else if (!strcmp(string, "stderr")) {
         c->auto_log_target = 0;
         c->log_target = PA_LOG_STDERR;
-    } else
+    } else if (pa_startswith(string, "file:")) {
+        char file_path[512];
+        int log_fd;
+
+        pa_strlcpy(file_path, string + 5, sizeof(file_path));
+
+        /* Open target file with user rights */
+        if ((log_fd = open(file_path, O_RDWR|O_TRUNC|O_CREAT, S_IRWXU)) >= 0) {
+             c->auto_log_target = 0;
+             c->log_target = PA_LOG_FD;
+             pa_log_set_fd(log_fd);
+        }
+        else {
+            printf("Failed to open target file %s, error : %s\n", file_path, 
pa_cstrerror(errno));
+            return -1;
+        }
+    }
+    else
         return -1;
 
     return 0;
@@ -218,22 +232,6 @@ int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const 
char *string) {
         c->log_level = PA_LOG_WARN;
     else if (pa_startswith(string, "err"))
         c->log_level = PA_LOG_ERROR;
-    else if (pa_startswith(string, "file:")) {
-        char file_path[512];
-
-        pa_strlcpy(file_path, string + 5, sizeof(file_path));
-
-        /* Open target file with user rights */
-        if ((log_fd = open(file_path, O_RDWR|O_TRUNC|O_CREAT, S_IRWXU)) >= 0) {
-             c->auto_log_target = 0;
-             c->log_target = PA_LOG_FD;
-             pa_log_set_fd(log_fd);
-        }
-        else {
-            printf("Failed to open target file %s, error : %s\n", file_path, 
pa_cstrerror(errno));
-            return -1;
-        }
-    }
     else
         return -1;
 
-- 
1.7.2.3

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to