summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChengwei Yang <chengwei.yang@intel.com>2013-08-23 17:13:46 +0800
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-08-23 11:59:23 +0100
commitd61daf50ce54976d1926afcb2353383cde5804b6 (patch)
treeed511dba1e596db30253f9572266837f4ca1def7
parent8203fe35da82cd9d3491ed8ac8a2a37cfa83f4e6 (diff)
downloaddbus-d61daf50ce54976d1926afcb2353383cde5804b6.tar.gz
Fix comment about atomic operations
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--dbus/dbus-server.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c
index efe7d1d8..2c2b9495 100644
--- a/dbus/dbus-server.c
+++ b/dbus/dbus-server.c
@@ -699,13 +699,11 @@ dbus_server_ref (DBusServer *server)
_dbus_return_val_if_fail (server != NULL, NULL);
- /* can't get the refcount without a side-effect */
old_refcount = _dbus_atomic_inc (&server->refcount);
#ifndef DBUS_DISABLE_CHECKS
if (_DBUS_UNLIKELY (old_refcount <= 0))
{
- /* undo side-effect first */
_dbus_atomic_dec (&server->refcount);
_dbus_warn_check_failed (_dbus_return_if_fail_warning_format,
_DBUS_FUNCTION_NAME, "old_refcount > 0",
@@ -736,13 +734,18 @@ dbus_server_unref (DBusServer *server)
_dbus_return_if_fail (server != NULL);
- /* can't get the refcount without a side-effect */
old_refcount = _dbus_atomic_dec (&server->refcount);
#ifndef DBUS_DISABLE_CHECKS
if (_DBUS_UNLIKELY (old_refcount <= 0))
{
- /* undo side-effect first */
+ /* undo side-effect first
+ * please do not try to simplify the code here by using
+ * _dbus_atomic_get(), why we don't use it is
+ * because it issues another atomic operation even though
+ * DBUS_DISABLE_CHECKS defined.
+ * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303
+ */
_dbus_atomic_inc (&server->refcount);
_dbus_warn_check_failed (_dbus_return_if_fail_warning_format,
_DBUS_FUNCTION_NAME, "old_refcount > 0",