cmap: Explain corner case in CMAP_FOR_EACH comment.
[cascardo/ovs.git] / lib / vlog.c
index a4aa2a0..3d0b87c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ VLOG_LEVELS
 BUILD_ASSERT_DECL(LOG_LOCAL0 == (16 << 3));
 
 /* The log modules. */
-struct ovs_list vlog_modules = OVS_LIST_INITIALIZER(&vlog_modules);
+static struct ovs_list vlog_modules = OVS_LIST_INITIALIZER(&vlog_modules);
 
 /* Protects the 'pattern' in all "struct destination"s, so that a race between
  * changing and reading the pattern does not cause an access to freed
@@ -438,15 +438,24 @@ vlog_reopen_log_file(void)
 void
 vlog_change_owner_unix(uid_t user, gid_t group)
 {
-    ovs_mutex_lock(&log_file_mutex);
-    int error = log_file_name ? chown(log_file_name, user, group) : 0;
+    struct ds err = DS_EMPTY_INITIALIZER;
+    int error;
 
+    ovs_mutex_lock(&log_file_mutex);
+    error = log_file_name ? chown(log_file_name, user, group) : 0;
     if (error) {
-        VLOG_FATAL("Failed to change %s ownership: %s.",
-                   log_file_name, ovs_strerror(errno));
+        /* Build the error message. We can not call VLOG_FATAL directly
+         * here because VLOG_FATAL() will try again to to acquire
+         * 'log_file_mutex' lock, causing deadlock.
+         */
+        ds_put_format(&err, "Failed to change %s ownership: %s.",
+                      log_file_name, ovs_strerror(errno));
     }
-
     ovs_mutex_unlock(&log_file_mutex);
+
+    if (error) {
+        VLOG_FATAL("%s", ds_steal_cstr(&err));
+    }
 }
 #endif