]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
various: comment static variables that are locked or otherwise OK
authorSimon McVittie <smcv@collabora.com>
Tue, 3 Sep 2013 11:33:37 +0000 (12:33 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 12 Dec 2019 08:36:24 +0000 (09:36 +0100)
dbus/dbus-bus.c
dbus/dbus-dataslot.c
dbus/dbus-internals.c
dbus/dbus-memory.c
dbus/dbus-pending-call.c
dbus/dbus-spawn-unix.c
dbus/dbus-sysdeps-thread-win.c
dbus/dbus-sysdeps-win.c
dbus/dbus-threads.c
dbus/dbus-userdb.c

index 1de9ca47e37d4ef48d11601dc456247a3b8eb920..35fc135e67c925153cd017e4acae22a40760de0b 100644 (file)
@@ -83,17 +83,18 @@ typedef struct
 } BusData;
 
 /** The slot we have reserved to store BusData.
+ * Protected by _DBUS_LOCK_connection_slots.
  */
 static dbus_int32_t bus_data_slot = -1;
 
 /** Number of bus types */
 #define N_BUS_TYPES 3
 
+/* Protected by _DBUS_LOCK_bus, except during shutdown, which can't safely
+ * be done in a threaded application anyway. */
 static DBusConnection *bus_connections[N_BUS_TYPES];
 static char *bus_connection_addresses[N_BUS_TYPES] = { NULL, NULL, NULL };
-
 static DBusBusType activation_bus_type = DBUS_BUS_STARTER;
-
 static dbus_bool_t initialized = FALSE;
 
 static void
index 18e20f606b98b3ce0d8b3ca9c5f0b705a56e2162..a4503a2949756b71ae6d63dd4143708ba67f93a8 100644 (file)
@@ -353,6 +353,7 @@ _dbus_data_slot_list_free (DBusDataSlotList *list)
 #include "dbus-test.h"
 #include <stdio.h>
 
+/* Test-only, does not need to be thread-safe */
 static int free_counter;
 
 static void
index 7420f2038aa385a6da842ad57193a77207994e45..7eb855012d42d60da3aa26c2035a64f407c40800 100644 (file)
  */
 const char *_dbus_no_memory_message = "Not enough memory";
 
+/* Not necessarily thread-safe, but if writes don't propagate between
+ * threads, the worst that will happen is that we duplicate work in more than
+ * one thread. */
 static dbus_bool_t warn_initted = FALSE;
+
+/* Not necessarily thread-safe, but if writes don't propagate between
+ * threads, the worst that will happen is that warnings get their default
+ * fatal/non-fatal nature. */
 static dbus_bool_t fatal_warnings = FALSE;
 static dbus_bool_t fatal_warnings_on_check_failed = TRUE;
 
index 98869d5751e7aa62fb6f605e8bd5793c07c7f390..5468561a4b386c9a08cba10a7eb43cf74e241556 100644 (file)
@@ -99,6 +99,7 @@
  */
 
 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
+/* Test-only, does not need to be thread-safe */
 static dbus_bool_t debug_initialized = FALSE;
 static int fail_nth = -1;
 static size_t fail_size = 0;
index d057b49be7b481436a5ee5b440c178fe6e27ffc8..84fdcb580d8ff530adf036180464c99f2e48f3a2 100644 (file)
@@ -101,6 +101,7 @@ _dbus_pending_call_trace_ref (DBusPendingCall *pending_call,
 #endif
 }
 
+/* protected by _DBUS_LOCK_pending_call_slots */
 static dbus_int32_t notify_user_data_slot = -1;
 
 /**
index 742c3a7af3af4b4a8905854dda1f666963ee904e..5550ffac19bac7fb31f04a00b2d47e19b33c9a37 100644 (file)
@@ -1153,6 +1153,8 @@ check_babysit_events (pid_t grandchild_pid,
     }
 }
 
+/* Only used in a single-threaded child process, does not need to be
+ * thread-safe */
 static int babysit_sigchld_pipe = -1;
 
 static void
index db38982515119d3afe1dfbd80b342edbbf045a8d..3b600fa911217dbce794bd63ac019843ef7ac9ad 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <windows.h>
 
+/* Protected by DllMain lock, effectively */
 static dbus_bool_t global_init_done = FALSE;
 static CRITICAL_SECTION init_lock;
 
@@ -54,7 +55,7 @@ struct DBusCondVar {
 
 static DWORD dbus_cond_event_tls = TLS_OUT_OF_INDEXES;
 
-
+/* Protected by DllMain lock, effectively */
 static HMODULE dbus_dll_hmodule;
 
 void *
index ee8b96788aaeb2e9fcd99398bb9b87f7472a95e0..46cbfe355773971e3ac08105f7c39a5426911bcf 100644 (file)
@@ -103,6 +103,10 @@ typedef MIB_TCPROW_OWNER_PID _MIB_TCPROW_EX;
 typedef MIB_TCPTABLE_OWNER_PID MIB_TCPTABLE_EX;
 typedef PMIB_TCPTABLE_OWNER_PID PMIB_TCPTABLE_EX;
 typedef DWORD (WINAPI *ProcAllocateAndGetTcpExtTableFromStack)(PMIB_TCPTABLE_EX*,BOOL,HANDLE,DWORD,DWORD);
+
+/* Not protected by a lock, but if we miss a write, all that
+ * happens is that the lazy initialization will happen in two threads
+ * concurrently - it results in the same value either way so that's OK */
 static ProcAllocateAndGetTcpExtTableFromStack lpfnAllocateAndGetTcpExTableFromStack = NULL;
 
 /**
index 3ebe9e706f3e5f8cf7ae057c42d2d34110fe2e26..8d7c03cde3bba63905ee7cdd33ff14a104432b1a 100644 (file)
@@ -26,6 +26,7 @@
 #include "dbus-threads-internal.h"
 #include "dbus-list.h"
 
+/* Protected by _dbus_threads_lock_platform_specific() */
 static int thread_init_generation = 0;
 
 /**
@@ -283,6 +284,7 @@ _dbus_condvar_wake_one (DBusCondVar *cond)
   _dbus_platform_condvar_wake_one (cond);
 }
 
+/* Protected by _dbus_threads_lock_platform_specific() */
 static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL };
 
 static void
index 666827488392b6d5d94a0c0bd4417528edb07602..d3225371fec84bdceb5c23c598c86b3e828bf82d 100644 (file)
@@ -222,6 +222,7 @@ _dbus_user_database_lookup (DBusUserDatabase *db,
     }
 }
 
+/* Protected by _DBUS_LOCK_system_users */
 static dbus_bool_t database_locked = FALSE;
 static DBusUserDatabase *system_db = NULL;
 static DBusString process_username;