summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-07-26 18:00:57 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-07-26 18:00:57 +0100
commit6ca26b7700b73087e00861440705577f7689b7a1 (patch)
treea67941047be590596116117180e8304afd32173f
parent0a6e7cb982d6ed5e3d4b3ecb8be21588b93487cc (diff)
parent104dc9383cd17d8202430d85e49ece66be7960a5 (diff)
downloaddbus-6ca26b7700b73087e00861440705577f7689b7a1.tar.gz
Merge branch 'dbus-1.4'
Conflicts: dbus/dbus-message.c
-rw-r--r--NEWS7
-rw-r--r--dbus/dbus-memory.c24
-rw-r--r--dbus/dbus-message.c27
3 files changed, 35 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index 1678fede..05ddf059 100644
--- a/NEWS
+++ b/NEWS
@@ -16,10 +16,9 @@ Other changes:
or dbus_connection_try_register_fallback fails, not ...ADDRESS_IN_USE,
and simplify object-path registration (fd.o #38874, Jiří Klimeš)
-• Consistently use atomic operations on the refcounts of DBusPendingCall,
- DBusServer, DBusMessageFilter and DBusObjectTree, as was done for
- DBusConnection in 1.4.12, and make the use of atomic operations
- more thorough for DBusConnection (fd.o #38005, Simon McVittie)
+• Consistently use atomic operations on everything that is ever manipulated
+ via atomic ops, as was done for changes to DBusConnection's refcount in
+ 1.4.12 (fd.o #38005, Simon McVittie)
• Fix a file descriptor leak when connecting to a TCP socket (fd.o #37258,
Simon McVittie)
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index a37759c0..ee40e82b 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -295,7 +295,7 @@ _dbus_decrement_fail_alloc_counter (void)
int
_dbus_get_malloc_blocks_outstanding (void)
{
- return n_blocks_outstanding.value;
+ return _dbus_atomic_get (&n_blocks_outstanding);
}
/**
@@ -634,10 +634,15 @@ dbus_free (void *memory)
check_guards (memory, TRUE);
if (memory)
{
- _dbus_atomic_dec (&n_blocks_outstanding);
-
- _dbus_assert (n_blocks_outstanding.value >= 0);
-
+#ifdef DBUS_DISABLE_ASSERT
+ _dbus_atomic_dec (&n_blocks_outstanding);
+#else
+ dbus_int32_t old_value;
+
+ old_value = _dbus_atomic_dec (&n_blocks_outstanding);
+ _dbus_assert (old_value >= 1);
+#endif
+
free (((unsigned char*)memory) - GUARD_START_OFFSET);
}
@@ -648,9 +653,14 @@ dbus_free (void *memory)
if (memory) /* we guarantee it's safe to free (NULL) */
{
#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_DISABLE_ASSERT
_dbus_atomic_dec (&n_blocks_outstanding);
-
- _dbus_assert (n_blocks_outstanding.value >= 0);
+#else
+ dbus_int32_t old_value;
+
+ old_value = _dbus_atomic_dec (&n_blocks_outstanding);
+ _dbus_assert (old_value >= 1);
+#endif
#endif
free (memory);
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index d9091714..dcb8d082 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -527,7 +527,8 @@ dbus_message_get_cached (void)
_dbus_assert (i < MAX_MESSAGE_CACHE_SIZE);
_dbus_assert (message != NULL);
- _dbus_assert (message->refcount.value == 0);
+ _dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
+
_dbus_assert (message->counters == NULL);
_DBUS_UNLOCK (message_cache);
@@ -587,8 +588,8 @@ dbus_message_cache_or_finalize (DBusMessage *message)
{
dbus_bool_t was_cached;
int i;
-
- _dbus_assert (message->refcount.value == 0);
+
+ _dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
/* This calls application code and has to be done first thing
* without holding the lock
@@ -650,8 +651,8 @@ dbus_message_cache_or_finalize (DBusMessage *message)
#endif
out:
- _dbus_assert (message->refcount.value == 0);
-
+ _dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
+
_DBUS_UNLOCK (message_cache);
if (!was_cached)
@@ -1044,7 +1045,7 @@ dbus_message_get_reply_serial (DBusMessage *message)
static void
dbus_message_finalize (DBusMessage *message)
{
- _dbus_assert (message->refcount.value == 0);
+ _dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
/* This calls application callbacks! */
_dbus_data_slot_list_free (&message->slot_list);
@@ -1061,8 +1062,8 @@ dbus_message_finalize (DBusMessage *message)
dbus_free(message->unix_fds);
#endif
- _dbus_assert (message->refcount.value == 0);
-
+ _dbus_assert (_dbus_atomic_get (&message->refcount) == 0);
+
dbus_free (message);
}
@@ -1081,7 +1082,7 @@ dbus_message_new_empty_header (void)
else
{
from_cache = FALSE;
- message = dbus_new (DBusMessage, 1);
+ message = dbus_new0 (DBusMessage, 1);
if (message == NULL)
return NULL;
#ifndef DBUS_DISABLE_CHECKS
@@ -1093,8 +1094,9 @@ dbus_message_new_empty_header (void)
message->n_unix_fds_allocated = 0;
#endif
}
-
- message->refcount.value = 1;
+
+ _dbus_atomic_inc (&message->refcount);
+
message->locked = FALSE;
#ifndef DBUS_DISABLE_CHECKS
message->in_cache = FALSE;
@@ -1457,7 +1459,8 @@ dbus_message_copy (const DBusMessage *message)
if (retval == NULL)
return NULL;
- retval->refcount.value = 1;
+ _dbus_atomic_inc (&retval->refcount);
+
retval->locked = FALSE;
#ifndef DBUS_DISABLE_CHECKS
retval->generation = message->generation;