mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 06:28:00 +02:00
Merge branch 'dbus-1.4'
Conflicts: dbus/dbus-message.c
This commit is contained in:
commit
6ca26b7700
3 changed files with 35 additions and 23 deletions
7
NEWS
7
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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue