/*
- * 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.
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
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