projects
/
platform
/
upstream
/
dbus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'dbus-1.6'
[platform/upstream/dbus.git]
/
dbus
/
dbus-connection.c
diff --git
a/dbus/dbus-connection.c
b/dbus/dbus-connection.c
index
ac0b2c0
..
86adaa5
100644
(file)
--- a/
dbus/dbus-connection.c
+++ b/
dbus/dbus-connection.c
@@
-336,8
+336,8
@@
struct DBusConnection
#ifndef DBUS_DISABLE_CHECKS
unsigned int have_connection_lock : 1; /**< Used to check locking */
#endif
#ifndef DBUS_DISABLE_CHECKS
unsigned int have_connection_lock : 1; /**< Used to check locking */
#endif
-
-#if
ndef DBUS_DISABLE_CHECKS
+
+#if
defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT)
int generation; /**< _dbus_current_generation that should correspond to this connection */
#endif
};
int generation; /**< _dbus_current_generation that should correspond to this connection */
#endif
};
@@
-446,7
+446,7
@@
_dbus_connection_wakeup_mainloop (DBusConnection *connection)
(*connection->wakeup_main_function) (connection->wakeup_main_data);
}
(*connection->wakeup_main_function) (connection->wakeup_main_data);
}
-#ifdef DBUS_
BUIL
D_TESTS
+#ifdef DBUS_
ENABLE_EMBEDDE
D_TESTS
/**
* Gets the locks so we can examine them
*
/**
* Gets the locks so we can examine them
*
@@
-1354,7
+1354,7
@@
_dbus_connection_new_for_transport (DBusTransport *transport)
connection->disconnected_message_arrived = FALSE;
connection->disconnected_message_processed = FALSE;
connection->disconnected_message_arrived = FALSE;
connection->disconnected_message_processed = FALSE;
-#if
ndef DBUS_DISABLE_CHECKS
+#if
defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT)
connection->generation = _dbus_current_generation;
#endif
connection->generation = _dbus_current_generation;
#endif
@@
-1531,7
+1531,7
@@
_dbus_connection_handle_watch (DBusWatch *watch,
return retval;
}
return retval;
}
-_DBUS_DEFINE_GLOBAL_LOCK (shared_connections);
+/* Protected by _DBUS_LOCK (shared_connections) */
static DBusHashTable *shared_connections = NULL;
static DBusList *shared_connections_no_guid = NULL;
static DBusHashTable *shared_connections = NULL;
static DBusList *shared_connections_no_guid = NULL;
@@
-1555,9
+1555,14
@@
static void
shared_connections_shutdown (void *data)
{
int n_entries;
shared_connections_shutdown (void *data)
{
int n_entries;
-
- _DBUS_LOCK (shared_connections);
-
+
+ if (!_DBUS_LOCK (shared_connections))
+ {
+ /* We'd have initialized locks before adding anything, so there
+ * can't be anything there. */
+ return;
+ }
+
/* This is a little bit unpleasant... better ideas? */
while ((n_entries = _dbus_hash_table_get_n_entries (shared_connections)) > 0)
{
/* This is a little bit unpleasant... better ideas? */
while ((n_entries = _dbus_hash_table_get_n_entries (shared_connections)) > 0)
{
@@
-1571,7
+1576,8
@@
shared_connections_shutdown (void *data)
_DBUS_UNLOCK (shared_connections);
close_connection_on_shutdown (connection);
_DBUS_UNLOCK (shared_connections);
close_connection_on_shutdown (connection);
- _DBUS_LOCK (shared_connections);
+ if (!_DBUS_LOCK (shared_connections))
+ _dbus_assert_not_reached ("global locks were already initialized");
/* The connection should now be dead and not in our hash ... */
_dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) < n_entries);
/* The connection should now be dead and not in our hash ... */
_dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) < n_entries);
@@
-1590,7
+1596,8
@@
shared_connections_shutdown (void *data)
{
_DBUS_UNLOCK (shared_connections);
close_connection_on_shutdown (connection);
{
_DBUS_UNLOCK (shared_connections);
close_connection_on_shutdown (connection);
- _DBUS_LOCK (shared_connections);
+ if (!_DBUS_LOCK (shared_connections))
+ _dbus_assert_not_reached ("global locks were already initialized");
connection = _dbus_list_pop_first (&shared_connections_no_guid);
}
}
connection = _dbus_list_pop_first (&shared_connections_no_guid);
}
}
@@
-1607,8
+1614,13
@@
connection_lookup_shared (DBusAddressEntry *entry,
_dbus_verbose ("checking for existing connection\n");
*result = NULL;
_dbus_verbose ("checking for existing connection\n");
*result = NULL;
-
- _DBUS_LOCK (shared_connections);
+
+ if (!_DBUS_LOCK (shared_connections))
+ {
+ /* If it was shared, we'd have initialized global locks when we put
+ * it in shared_connections. */
+ return FALSE;
+ }
if (shared_connections == NULL)
{
if (shared_connections == NULL)
{
@@
-1706,7
+1718,8
@@
connection_record_shared_unlocked (DBusConnection *connection,
if (guid == NULL)
{
if (guid == NULL)
{
- _DBUS_LOCK (shared_connections);
+ if (!_DBUS_LOCK (shared_connections))
+ return FALSE;
if (!_dbus_list_prepend (&shared_connections_no_guid, connection))
{
if (!_dbus_list_prepend (&shared_connections_no_guid, connection))
{
@@
-1733,8
+1746,14
@@
connection_record_shared_unlocked (DBusConnection *connection,
dbus_free (guid_key);
return FALSE;
}
dbus_free (guid_key);
return FALSE;
}
-
- _DBUS_LOCK (shared_connections);
+
+ if (!_DBUS_LOCK (shared_connections))
+ {
+ dbus_free (guid_in_connection);
+ dbus_free (guid_key);
+ return FALSE;
+ }
+
_dbus_assert (shared_connections != NULL);
if (!_dbus_hash_table_insert_string (shared_connections,
_dbus_assert (shared_connections != NULL);
if (!_dbus_hash_table_insert_string (shared_connections,
@@
-1765,9
+1784,14
@@
connection_forget_shared_unlocked (DBusConnection *connection)
if (!connection->shareable)
return;
if (!connection->shareable)
return;
-
- _DBUS_LOCK (shared_connections);
-
+
+ if (!_DBUS_LOCK (shared_connections))
+ {
+ /* If it was shared, we'd have initialized global locks when we put
+ * it in the table; so it can't be there. */
+ return;
+ }
+
if (connection->server_guid != NULL)
{
_dbus_verbose ("dropping connection to %s out of the shared table\n",
if (connection->server_guid != NULL)
{
_dbus_verbose ("dropping connection to %s out of the shared table\n",
@@
-2150,7
+2174,7
@@
_dbus_connection_close_if_only_one_ref (DBusConnection *connection)
* relatively long time for memory, if they were only willing to block
* briefly then we retry for memory at a rapid rate.
*
* relatively long time for memory, if they were only willing to block
* briefly then we retry for memory at a rapid rate.
*
- * @timeout_milliseconds the timeout requested for blocking
+ * @
param
timeout_milliseconds the timeout requested for blocking
*/
static void
_dbus_memory_pause_based_on_timeout (int timeout_milliseconds)
*/
static void
_dbus_memory_pause_based_on_timeout (int timeout_milliseconds)
@@
-2388,7
+2412,7
@@
_dbus_connection_block_pending_call (DBusPendingCall *pending)
* below
*/
timeout = _dbus_pending_call_get_timeout_unlocked (pending);
* below
*/
timeout = _dbus_pending_call_get_timeout_unlocked (pending);
- _dbus_get_
current
_time (&start_tv_sec, &start_tv_usec);
+ _dbus_get_
monotonic
_time (&start_tv_sec, &start_tv_usec);
if (timeout)
{
timeout_milliseconds = dbus_timeout_get_interval (timeout);
if (timeout)
{
timeout_milliseconds = dbus_timeout_get_interval (timeout);
@@
-2445,7
+2469,7
@@
_dbus_connection_block_pending_call (DBusPendingCall *pending)
return;
}
return;
}
- _dbus_get_
current
_time (&tv_sec, &tv_usec);
+ _dbus_get_
monotonic
_time (&tv_sec, &tv_usec);
elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 +
(tv_usec - start_tv_usec) / 1000;
elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 +
(tv_usec - start_tv_usec) / 1000;
@@
-3938,7
+3962,7
@@
_dbus_connection_pop_message_link_unlocked (DBusConnection *connection)
link = _dbus_list_pop_first_link (&connection->incoming_messages);
connection->n_incoming -= 1;
link = _dbus_list_pop_first_link (&connection->incoming_messages);
connection->n_incoming -= 1;
- _dbus_verbose ("Message %p (%s %s %s %s
'%s'
) removed from incoming queue %p, %d incoming\n",
+ _dbus_verbose ("Message %p (%s %s %s %s
sig:'%s' serial:%u
) removed from incoming queue %p, %d incoming\n",
link->data,
dbus_message_type_to_string (dbus_message_get_type (link->data)),
dbus_message_get_path (link->data) ?
link->data,
dbus_message_type_to_string (dbus_message_get_type (link->data)),
dbus_message_get_path (link->data) ?
@@
-3951,6
+3975,7
@@
_dbus_connection_pop_message_link_unlocked (DBusConnection *connection)
dbus_message_get_member (link->data) :
"no member",
dbus_message_get_signature (link->data),
dbus_message_get_member (link->data) :
"no member",
dbus_message_get_signature (link->data),
+ dbus_message_get_serial (link->data),
connection, connection->n_incoming);
_dbus_message_trace_ref (link->data, -1, -1,
connection, connection->n_incoming);
_dbus_message_trace_ref (link->data, -1, -1,
@@
-5852,8
+5877,8
@@
dbus_connection_list_registered (DBusConnection *connection,
return retval;
}
return retval;
}
-static DBusDataSlotAllocator slot_allocator
;
-
_DBUS_DEFINE_GLOBAL_LOCK (connection_slots
);
+static DBusDataSlotAllocator slot_allocator
=
+
_DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (connection_slots)
);
/**
* Allocates an integer ID to be used for storing application-specific
/**
* Allocates an integer ID to be used for storing application-specific
@@
-5873,7
+5898,6
@@
dbus_bool_t
dbus_connection_allocate_data_slot (dbus_int32_t *slot_p)
{
return _dbus_data_slot_allocator_alloc (&slot_allocator,
dbus_connection_allocate_data_slot (dbus_int32_t *slot_p)
{
return _dbus_data_slot_allocator_alloc (&slot_allocator,
- &_DBUS_LOCK_NAME (connection_slots),
slot_p);
}
slot_p);
}
@@
-5974,7
+5998,8
@@
dbus_connection_get_data (DBusConnection *connection,
void *res;
_dbus_return_val_if_fail (connection != NULL, NULL);
void *res;
_dbus_return_val_if_fail (connection != NULL, NULL);
-
+ _dbus_return_val_if_fail (slot >= 0, NULL);
+
SLOTS_LOCK (connection);
res = _dbus_data_slot_list_get (&slot_allocator,
SLOTS_LOCK (connection);
res = _dbus_data_slot_list_get (&slot_allocator,
@@
-6258,7
+6283,7
@@
dbus_connection_get_outgoing_unix_fds (DBusConnection *connection)
return res;
}
return res;
}
-#ifdef DBUS_
BUIL
D_TESTS
+#ifdef DBUS_
ENABLE_EMBEDDE
D_TESTS
/**
* Returns the address of the transport object of this connection
*
/**
* Returns the address of the transport object of this connection
*