summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-05 12:50:11 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-05 12:50:11 +0100
commit4c53a38ab5dde6a9c236221462344146ca294f83 (patch)
tree953d62ed6d48a333bd1903dd9c69792ce7aac5e6
parent20568ffb1fdcf54f54bc5d8b4928f3e485c5ab25 (diff)
parentd9d130d5fa9a57a3c900f33a36c54ab576eb8972 (diff)
Merge branch 'dbus-1.8'
-rw-r--r--NEWS17
-rw-r--r--dbus/dbus-resources.c52
-rw-r--r--dbus/dbus-transport.c4
3 files changed, 65 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 7c5d1399..9da0c293 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,22 @@
D-Bus 1.9.16 (UNRELEASED)
==
-...
+Fixes:
+
+• Add locking to DBusCounter's reference count and notify function
+ (fd.o #89297, Adrian Szyndela)
+
+• Ensure that DBusTransport's reference count is protected by the
+ corresponding DBusConnection's lock (fd.o #90312, Adrian Szyndela)
+
+• Correctly release DBusServer mutex before early-return if we run out
+ of memory while copying authentication mechanisms (fd.o #90004,
+ Ralf Habacker)
+
+• Fix some missing \n in verbose (debug log) messages (fd.o #90004,
+ Ralf Habacker)
+
+• Clean up some memory leaks in test code (fd.o #90004, Ralf Habacker)
D-Bus 1.9.14 (2015-03-02)
==
diff --git a/dbus/dbus-resources.c b/dbus/dbus-resources.c
index 80fb55b2..0617eae2 100644
--- a/dbus/dbus-resources.c
+++ b/dbus/dbus-resources.c
@@ -69,6 +69,7 @@ struct DBusCounter
DBusCounterNotifyFunction notify_function; /**< notify function */
void *notify_data; /**< data for notify function */
dbus_bool_t notify_pending : 1; /**< TRUE if the guard value has been crossed */
+ DBusRMutex *mutex; /**< Lock on the entire DBusCounter */
};
/** @} */ /* end of resource limits internals docs */
@@ -95,6 +96,13 @@ _dbus_counter_new (void)
counter->refcount = 1;
+ _dbus_rmutex_new_at_location (&counter->mutex);
+ if (counter->mutex == NULL)
+ {
+ dbus_free (counter);
+ counter = NULL;
+ }
+
return counter;
}
@@ -107,10 +115,14 @@ _dbus_counter_new (void)
DBusCounter *
_dbus_counter_ref (DBusCounter *counter)
{
+ _dbus_rmutex_lock (counter->mutex);
+
_dbus_assert (counter->refcount > 0);
counter->refcount += 1;
+ _dbus_rmutex_unlock (counter->mutex);
+
return counter;
}
@@ -123,13 +135,20 @@ _dbus_counter_ref (DBusCounter *counter)
void
_dbus_counter_unref (DBusCounter *counter)
{
+ dbus_bool_t last_ref = FALSE;
+
+ _dbus_rmutex_lock (counter->mutex);
+
_dbus_assert (counter->refcount > 0);
counter->refcount -= 1;
+ last_ref = (counter->refcount == 0);
+
+ _dbus_rmutex_unlock (counter->mutex);
- if (counter->refcount == 0)
+ if (last_ref)
{
-
+ _dbus_rmutex_free_at_location (&counter->mutex);
dbus_free (counter);
}
}
@@ -148,7 +167,11 @@ void
_dbus_counter_adjust_size (DBusCounter *counter,
long delta)
{
- long old = counter->size_value;
+ long old = 0;
+
+ _dbus_rmutex_lock (counter->mutex);
+
+ old = counter->size_value;
counter->size_value += delta;
@@ -168,6 +191,8 @@ _dbus_counter_adjust_size (DBusCounter *counter,
(old >= counter->notify_size_guard_value &&
counter->size_value < counter->notify_size_guard_value)))
counter->notify_pending = TRUE;
+
+ _dbus_rmutex_unlock (counter->mutex);
}
/**
@@ -181,11 +206,20 @@ _dbus_counter_adjust_size (DBusCounter *counter,
void
_dbus_counter_notify (DBusCounter *counter)
{
+ DBusCounterNotifyFunction notify_function = NULL;
+ void *notify_data = NULL;
+
+ _dbus_rmutex_lock (counter->mutex);
if (counter->notify_pending)
{
counter->notify_pending = FALSE;
- (* counter->notify_function) (counter, counter->notify_data);
+ notify_function = counter->notify_function;
+ notify_data = counter->notify_data;
}
+ _dbus_rmutex_unlock (counter->mutex);
+
+ if (notify_function != NULL)
+ (* notify_function) (counter, notify_data);
}
/**
@@ -202,7 +236,11 @@ void
_dbus_counter_adjust_unix_fd (DBusCounter *counter,
long delta)
{
- long old = counter->unix_fd_value;
+ long old = 0;
+
+ _dbus_rmutex_lock (counter->mutex);
+
+ old = counter->unix_fd_value;
counter->unix_fd_value += delta;
@@ -222,6 +260,8 @@ _dbus_counter_adjust_unix_fd (DBusCounter *counter,
(old >= counter->notify_unix_fd_guard_value &&
counter->unix_fd_value < counter->notify_unix_fd_guard_value)))
counter->notify_pending = TRUE;
+
+ _dbus_rmutex_unlock (counter->mutex);
}
/**
@@ -266,11 +306,13 @@ _dbus_counter_set_notify (DBusCounter *counter,
DBusCounterNotifyFunction function,
void *user_data)
{
+ _dbus_rmutex_lock (counter->mutex);
counter->notify_size_guard_value = size_guard_value;
counter->notify_unix_fd_guard_value = unix_fd_guard_value;
counter->notify_function = function;
counter->notify_data = user_data;
counter->notify_pending = FALSE;
+ _dbus_rmutex_unlock (counter->mutex);
}
#ifdef DBUS_ENABLE_STATS
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 5ceab0a9..a43e7bbe 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -63,6 +63,7 @@ live_messages_notify (DBusCounter *counter,
{
DBusTransport *transport = user_data;
+ _dbus_connection_lock (transport->connection);
_dbus_transport_ref (transport);
#if 0
@@ -77,12 +78,11 @@ live_messages_notify (DBusCounter *counter,
*/
if (transport->vtable->live_messages_changed)
{
- _dbus_connection_lock (transport->connection);
(* transport->vtable->live_messages_changed) (transport);
- _dbus_connection_unlock (transport->connection);
}
_dbus_transport_unref (transport);
+ _dbus_connection_unlock (transport->connection);
}
/**