mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 09:16:17 +01:00
GDBus: switch to struct-embedded GMutex and GCond
Now that we have those, we should use them. https://bugzilla.gnome.org/show_bug.cgi?id=660739
This commit is contained in:
parent
e03db42792
commit
5f48e2cde5
@ -280,7 +280,7 @@ _g_strv_has_string (const gchar* const *haystack,
|
||||
#else
|
||||
// TODO: for some reason this doesn't work on Windows
|
||||
#define CONNECTION_ENSURE_LOCK(obj) do { \
|
||||
if (G_UNLIKELY (g_mutex_trylock((obj)->lock))) \
|
||||
if (G_UNLIKELY (g_mutex_trylock(&(obj)->lock))) \
|
||||
{ \
|
||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||
"CONNECTION_ENSURE_LOCK: GDBusConnection object lock is not locked"); \
|
||||
@ -289,11 +289,11 @@ _g_strv_has_string (const gchar* const *haystack,
|
||||
#endif
|
||||
|
||||
#define CONNECTION_LOCK(obj) do { \
|
||||
g_mutex_lock ((obj)->lock); \
|
||||
g_mutex_lock (&(obj)->lock); \
|
||||
} while (FALSE)
|
||||
|
||||
#define CONNECTION_UNLOCK(obj) do { \
|
||||
g_mutex_unlock ((obj)->lock); \
|
||||
g_mutex_unlock (&(obj)->lock); \
|
||||
} while (FALSE)
|
||||
|
||||
/**
|
||||
@ -314,12 +314,12 @@ struct _GDBusConnection
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/* object-wide lock */
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
|
||||
/* A lock used in the init() method of the GInitable interface - see comments
|
||||
* in initable_init() for why a separate lock is needed
|
||||
*/
|
||||
GMutex *init_lock;
|
||||
GMutex init_lock;
|
||||
|
||||
/* Set (by loading the contents of /var/lib/dbus/machine-id) the first time
|
||||
* someone calls org.freedesktop.DBus.GetMachineId()
|
||||
@ -541,8 +541,8 @@ g_dbus_connection_finalize (GObject *object)
|
||||
|
||||
g_free (connection->machine_id);
|
||||
|
||||
g_mutex_free (connection->init_lock);
|
||||
g_mutex_free (connection->lock);
|
||||
g_mutex_clear (&connection->init_lock);
|
||||
g_mutex_clear (&connection->lock);
|
||||
|
||||
G_OBJECT_CLASS (g_dbus_connection_parent_class)->finalize (object);
|
||||
}
|
||||
@ -903,8 +903,8 @@ g_dbus_connection_class_init (GDBusConnectionClass *klass)
|
||||
static void
|
||||
g_dbus_connection_init (GDBusConnection *connection)
|
||||
{
|
||||
connection->lock = g_mutex_new ();
|
||||
connection->init_lock = g_mutex_new ();
|
||||
g_mutex_init (&connection->lock);
|
||||
g_mutex_init (&connection->init_lock);
|
||||
|
||||
connection->map_method_serial_to_send_message_data = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
@ -2271,7 +2271,7 @@ initable_init (GInitable *initable,
|
||||
* callbacks above needs the lock during initialization (for message
|
||||
* bus connections we do a synchronous Hello() call on the bus).
|
||||
*/
|
||||
g_mutex_lock (connection->init_lock);
|
||||
g_mutex_lock (&connection->init_lock);
|
||||
|
||||
ret = FALSE;
|
||||
|
||||
@ -2438,7 +2438,7 @@ initable_init (GInitable *initable,
|
||||
g_propagate_error (error, g_error_copy (connection->initialization_error));
|
||||
}
|
||||
|
||||
g_mutex_unlock (connection->init_lock);
|
||||
g_mutex_unlock (&connection->init_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
struct _GDBusInterfaceSkeletonPrivate
|
||||
{
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
|
||||
GDBusObject *object;
|
||||
GDBusInterfaceSkeletonFlags flags;
|
||||
@ -89,7 +89,7 @@ g_dbus_interface_skeleton_finalize (GObject *object)
|
||||
if (interface->priv->object != NULL)
|
||||
g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object);
|
||||
|
||||
g_mutex_free (interface->priv->lock);
|
||||
g_mutex_clear (&interface->priv->lock);
|
||||
|
||||
G_OBJECT_CLASS (g_dbus_interface_skeleton_parent_class)->finalize (object);
|
||||
}
|
||||
@ -233,7 +233,7 @@ static void
|
||||
g_dbus_interface_skeleton_init (GDBusInterfaceSkeleton *interface)
|
||||
{
|
||||
interface->priv = G_TYPE_INSTANCE_GET_PRIVATE (interface, G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonPrivate);
|
||||
interface->priv->lock = g_mutex_new ();
|
||||
g_mutex_init (&interface->priv->lock);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@ -270,16 +270,16 @@ g_dbus_interface_skeleton_set_flags (GDBusInterfaceSkeleton *interface_,
|
||||
GDBusInterfaceSkeletonFlags flags)
|
||||
{
|
||||
g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
|
||||
g_mutex_lock (interface_->priv->lock);
|
||||
g_mutex_lock (&interface_->priv->lock);
|
||||
if (interface_->priv->flags != flags)
|
||||
{
|
||||
interface_->priv->flags = flags;
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
g_object_notify (G_OBJECT (interface_), "g-flags");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,9 +381,9 @@ g_dbus_interface_skeleton_get_object (GDBusInterface *interface_)
|
||||
{
|
||||
GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (interface_);
|
||||
GDBusObject *ret;
|
||||
g_mutex_lock (interface->priv->lock);
|
||||
g_mutex_lock (&interface->priv->lock);
|
||||
ret = interface->priv->object;
|
||||
g_mutex_unlock (interface->priv->lock);
|
||||
g_mutex_unlock (&interface->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -392,13 +392,13 @@ g_dbus_interface_skeleton_set_object (GDBusInterface *interface_,
|
||||
GDBusObject *object)
|
||||
{
|
||||
GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (interface_);
|
||||
g_mutex_lock (interface->priv->lock);
|
||||
g_mutex_lock (&interface->priv->lock);
|
||||
if (interface->priv->object != NULL)
|
||||
g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object);
|
||||
interface->priv->object = object;
|
||||
if (object != NULL)
|
||||
g_object_add_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object);
|
||||
g_mutex_unlock (interface->priv->lock);
|
||||
g_mutex_unlock (&interface->priv->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -463,12 +463,12 @@ dispatch_in_thread_func (GIOSchedulerJob *job,
|
||||
GDBusObject *object;
|
||||
gboolean authorized;
|
||||
|
||||
g_mutex_lock (data->interface->priv->lock);
|
||||
g_mutex_lock (&data->interface->priv->lock);
|
||||
flags = data->interface->priv->flags;
|
||||
object = data->interface->priv->object;
|
||||
if (object != NULL)
|
||||
g_object_ref (object);
|
||||
g_mutex_unlock (data->interface->priv->lock);
|
||||
g_mutex_unlock (&data->interface->priv->lock);
|
||||
|
||||
/* first check on the enclosing object (if any), then the interface */
|
||||
authorized = TRUE;
|
||||
@ -542,12 +542,12 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface
|
||||
g_return_if_fail (method_call_func != NULL);
|
||||
g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
|
||||
|
||||
g_mutex_lock (interface->priv->lock);
|
||||
g_mutex_lock (&interface->priv->lock);
|
||||
flags = interface->priv->flags;
|
||||
object = interface->priv->object;
|
||||
if (object != NULL)
|
||||
g_object_ref (object);
|
||||
g_mutex_unlock (interface->priv->lock);
|
||||
g_mutex_unlock (&interface->priv->lock);
|
||||
|
||||
/* optimization for the common case where
|
||||
*
|
||||
@ -636,9 +636,9 @@ g_dbus_interface_skeleton_get_connection (GDBusInterfaceSkeleton *interface_)
|
||||
{
|
||||
GDBusConnection *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
|
||||
g_mutex_lock (interface_->priv->lock);
|
||||
g_mutex_lock (&interface_->priv->lock);
|
||||
ret = interface_->priv->connection;
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -658,9 +658,9 @@ g_dbus_interface_skeleton_get_object_path (GDBusInterfaceSkeleton *interface_)
|
||||
{
|
||||
const gchar *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
|
||||
g_mutex_lock (interface_->priv->lock);
|
||||
g_mutex_lock (&interface_->priv->lock);
|
||||
ret = interface_->priv->object_path;
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -693,7 +693,7 @@ g_dbus_interface_skeleton_export (GDBusInterfaceSkeleton *interface_,
|
||||
g_return_val_if_fail (g_variant_is_object_path (object_path), 0);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, 0);
|
||||
|
||||
g_mutex_lock (interface_->priv->lock);
|
||||
g_mutex_lock (&interface_->priv->lock);
|
||||
|
||||
ret = FALSE;
|
||||
if (interface_->priv->registration_id > 0)
|
||||
@ -731,7 +731,7 @@ g_dbus_interface_skeleton_export (GDBusInterfaceSkeleton *interface_,
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -750,7 +750,7 @@ g_dbus_interface_skeleton_unexport (GDBusInterfaceSkeleton *interface_)
|
||||
g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
|
||||
g_return_if_fail (interface_->priv->registration_id > 0);
|
||||
|
||||
g_mutex_lock (interface_->priv->lock);
|
||||
g_mutex_lock (&interface_->priv->lock);
|
||||
|
||||
g_assert (interface_->priv->connection != NULL);
|
||||
g_assert (interface_->priv->object_path != NULL);
|
||||
@ -766,7 +766,7 @@ g_dbus_interface_skeleton_unexport (GDBusInterfaceSkeleton *interface_)
|
||||
interface_->priv->hooked_vtable = NULL;
|
||||
interface_->priv->registration_id = 0;
|
||||
|
||||
g_mutex_unlock (interface_->priv->lock);
|
||||
g_mutex_unlock (&interface_->priv->lock);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
@ -125,7 +125,7 @@
|
||||
|
||||
struct _GDBusObjectManagerClientPrivate
|
||||
{
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
|
||||
GBusType bus_type;
|
||||
GDBusConnection *connection;
|
||||
@ -214,7 +214,7 @@ g_dbus_object_manager_client_finalize (GObject *object)
|
||||
if (manager->priv->get_proxy_type_destroy_notify != NULL)
|
||||
manager->priv->get_proxy_type_destroy_notify (manager->priv->get_proxy_type_user_data);
|
||||
|
||||
g_mutex_free (manager->priv->lock);
|
||||
g_mutex_clear (&manager->priv->lock);
|
||||
|
||||
if (G_OBJECT_CLASS (g_dbus_object_manager_client_parent_class)->finalize != NULL)
|
||||
G_OBJECT_CLASS (g_dbus_object_manager_client_parent_class)->finalize (object);
|
||||
@ -572,7 +572,7 @@ g_dbus_object_manager_client_init (GDBusObjectManagerClient *manager)
|
||||
manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
|
||||
G_TYPE_DBUS_OBJECT_MANAGER_CLIENT,
|
||||
GDBusObjectManagerClientPrivate);
|
||||
manager->priv->lock = g_mutex_new ();
|
||||
g_mutex_init (&manager->priv->lock);
|
||||
manager->priv->map_object_path_to_object_proxy = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
@ -901,9 +901,9 @@ g_dbus_object_manager_client_get_connection (GDBusObjectManagerClient *manager)
|
||||
{
|
||||
GDBusConnection *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager), NULL);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = manager->priv->connection;
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -923,9 +923,9 @@ g_dbus_object_manager_client_get_name (GDBusObjectManagerClient *manager)
|
||||
{
|
||||
const gchar *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager), NULL);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = manager->priv->name;
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -945,9 +945,9 @@ g_dbus_object_manager_client_get_flags (GDBusObjectManagerClient *manager)
|
||||
{
|
||||
GDBusObjectManagerClientFlags ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager), G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = manager->priv->flags;
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -970,9 +970,9 @@ g_dbus_object_manager_client_get_name_owner (GDBusObjectManagerClient *manager)
|
||||
{
|
||||
gchar *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager), NULL);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = g_strdup (manager->priv->name_owner);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -994,15 +994,15 @@ signal_cb (GDBusConnection *connection,
|
||||
GDBusObjectProxy *object_proxy;
|
||||
GDBusInterface *interface;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
object_proxy = g_hash_table_lookup (manager->priv->map_object_path_to_object_proxy, object_path);
|
||||
if (object_proxy == NULL)
|
||||
{
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
goto out;
|
||||
}
|
||||
g_object_ref (object_proxy);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
//g_debug ("yay, signal_cb %s %s: %s\n", signal_name, object_path, g_variant_print (parameters, TRUE));
|
||||
|
||||
@ -1224,7 +1224,7 @@ on_notify_g_name_owner (GObject *object,
|
||||
gchar *old_name_owner;
|
||||
gchar *new_name_owner;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
old_name_owner = manager->priv->name_owner;
|
||||
new_name_owner = g_dbus_proxy_get_name_owner (manager->priv->control_proxy);
|
||||
manager->priv->name_owner = NULL;
|
||||
@ -1239,7 +1239,7 @@ on_notify_g_name_owner (GObject *object,
|
||||
g_list_foreach (proxies, (GFunc) g_object_ref, NULL);
|
||||
g_hash_table_remove_all (manager->priv->map_object_path_to_object_proxy);
|
||||
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
/* do the :name-owner notify with a NULL name - this way the user knows
|
||||
* the ::object-proxy-removed following is because the name owner went
|
||||
@ -1260,7 +1260,7 @@ on_notify_g_name_owner (GObject *object,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
}
|
||||
|
||||
if (new_name_owner != NULL)
|
||||
@ -1299,9 +1299,9 @@ on_notify_g_name_owner (GObject *object,
|
||||
/* do the :name-owner notify *AFTER* emitting ::object-proxy-added signals - this
|
||||
* way the user knows that the signals were emitted because the name owner came back
|
||||
*/
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
manager->priv->name_owner = new_name_owner;
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
g_object_notify (G_OBJECT (manager), "name-owner");
|
||||
|
||||
}
|
||||
@ -1422,7 +1422,7 @@ add_interfaces (GDBusObjectManagerClient *manager,
|
||||
|
||||
g_return_if_fail (g_dbus_is_unique_name (name_owner));
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
interface_added_signals = NULL;
|
||||
added = FALSE;
|
||||
@ -1526,7 +1526,7 @@ add_interfaces (GDBusObjectManagerClient *manager,
|
||||
g_variant_unref (properties);
|
||||
}
|
||||
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
/* now that we don't hold the lock any more, emit signals */
|
||||
for (l = interface_added_signals; l != NULL; l = l->next)
|
||||
@ -1559,7 +1559,7 @@ remove_interfaces (GDBusObjectManagerClient *manager,
|
||||
guint num_interfaces;
|
||||
guint num_interfaces_to_remove;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
op = g_hash_table_lookup (manager->priv->map_object_path_to_object_proxy, object_path);
|
||||
if (op == NULL)
|
||||
@ -1567,7 +1567,7 @@ remove_interfaces (GDBusObjectManagerClient *manager,
|
||||
g_warning ("%s: Processing InterfaceRemoved signal for path %s but no object proxy exists",
|
||||
G_STRLOC,
|
||||
object_path);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -1583,14 +1583,14 @@ remove_interfaces (GDBusObjectManagerClient *manager,
|
||||
{
|
||||
g_object_ref (op);
|
||||
g_warn_if_fail (g_hash_table_remove (manager->priv->map_object_path_to_object_proxy, object_path));
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
g_signal_emit_by_name (manager, "object-removed", op);
|
||||
g_object_unref (op);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_ref (op);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
for (n = 0; interface_names != NULL && interface_names[n] != NULL; n++)
|
||||
{
|
||||
GDBusInterface *interface;
|
||||
@ -1683,11 +1683,11 @@ g_dbus_object_manager_client_get_object (GDBusObjectManager *_manager,
|
||||
GDBusObjectManagerClient *manager = G_DBUS_OBJECT_MANAGER_CLIENT (_manager);
|
||||
GDBusObject *ret;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = g_hash_table_lookup (manager->priv->map_object_path_to_object_proxy, object_path);
|
||||
if (ret != NULL)
|
||||
g_object_ref (ret);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1720,10 +1720,10 @@ g_dbus_object_manager_client_get_objects (GDBusObjectManager *_manager)
|
||||
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager), NULL);
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = g_hash_table_get_values (manager->priv->map_object_path_to_object_proxy);
|
||||
g_list_foreach (ret, (GFunc) g_object_ref, NULL);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ static gboolean g_dbus_object_manager_server_unexport_unlocked (GDBusObjectManag
|
||||
|
||||
struct _GDBusObjectManagerServerPrivate
|
||||
{
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
GDBusConnection *connection;
|
||||
gchar *object_path;
|
||||
gchar *object_path_ending_in_slash;
|
||||
@ -117,7 +117,7 @@ g_dbus_object_manager_server_finalize (GObject *object)
|
||||
g_free (manager->priv->object_path);
|
||||
g_free (manager->priv->object_path_ending_in_slash);
|
||||
|
||||
g_mutex_free (manager->priv->lock);
|
||||
g_mutex_clear (&manager->priv->lock);
|
||||
|
||||
if (G_OBJECT_CLASS (g_dbus_object_manager_server_parent_class)->finalize != NULL)
|
||||
G_OBJECT_CLASS (g_dbus_object_manager_server_parent_class)->finalize (object);
|
||||
@ -134,9 +134,9 @@ g_dbus_object_manager_server_get_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONNECTION:
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
g_value_set_object (value, manager->priv->connection);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
@ -230,7 +230,7 @@ g_dbus_object_manager_server_init (GDBusObjectManagerServer *manager)
|
||||
manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
|
||||
G_TYPE_DBUS_OBJECT_MANAGER_SERVER,
|
||||
GDBusObjectManagerServerPrivate);
|
||||
manager->priv->lock = g_mutex_new ();
|
||||
g_mutex_init (&manager->priv->lock);
|
||||
manager->priv->map_object_path_to_data = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
@ -277,11 +277,11 @@ g_dbus_object_manager_server_set_connection (GDBusObjectManagerServer *manager,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager));
|
||||
g_return_if_fail (connection == NULL || G_IS_DBUS_CONNECTION (connection));
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
if (manager->priv->connection == connection)
|
||||
{
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ g_dbus_object_manager_server_set_connection (GDBusObjectManagerServer *manager,
|
||||
if (manager->priv->connection != NULL)
|
||||
export_all (manager);
|
||||
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
g_object_notify (G_OBJECT (manager), "connection");
|
||||
out:
|
||||
@ -320,9 +320,9 @@ g_dbus_object_manager_server_get_connection (GDBusObjectManagerServer *manager)
|
||||
{
|
||||
GDBusConnection *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager), NULL);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = manager->priv->connection != NULL ? g_object_ref (manager->priv->connection) : NULL;
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -406,10 +406,10 @@ on_interface_added (GDBusObject *object,
|
||||
{
|
||||
RegistrationData *data = user_data;
|
||||
const gchar *object_path;
|
||||
g_mutex_lock (data->manager->priv->lock);
|
||||
g_mutex_lock (&data->manager->priv->lock);
|
||||
object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));
|
||||
registration_data_export_interface (data, G_DBUS_INTERFACE_SKELETON (interface), object_path);
|
||||
g_mutex_unlock (data->manager->priv->lock);
|
||||
g_mutex_unlock (&data->manager->priv->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -418,9 +418,9 @@ on_interface_removed (GDBusObject *object,
|
||||
gpointer user_data)
|
||||
{
|
||||
RegistrationData *data = user_data;
|
||||
g_mutex_lock (data->manager->priv->lock);
|
||||
g_mutex_lock (&data->manager->priv->lock);
|
||||
registration_data_unexport_interface (data, G_DBUS_INTERFACE_SKELETON (interface));
|
||||
g_mutex_unlock (data->manager->priv->lock);
|
||||
g_mutex_unlock (&data->manager->priv->lock);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@ -535,10 +535,10 @@ g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager,
|
||||
GDBusObjectSkeleton *object)
|
||||
{
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager));
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
g_dbus_object_manager_server_export_unlocked (manager, object,
|
||||
g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -569,7 +569,7 @@ g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT (object));
|
||||
g_return_if_fail (g_str_has_prefix (orig_object_path, manager->priv->object_path_ending_in_slash));
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
object_path = g_strdup (orig_object_path);
|
||||
count = 1;
|
||||
@ -589,7 +589,7 @@ g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager,
|
||||
|
||||
g_dbus_object_manager_server_export_unlocked (manager, object, object_path);
|
||||
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
if (modified)
|
||||
g_dbus_object_skeleton_set_object_path (G_DBUS_OBJECT_SKELETON (object), object_path);
|
||||
@ -658,9 +658,9 @@ g_dbus_object_manager_server_unexport (GDBusObjectManagerServer *manager,
|
||||
{
|
||||
gboolean ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager), FALSE);
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
ret = g_dbus_object_manager_server_unexport_unlocked (manager, object_path);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ manager_method_call (GDBusConnection *connection,
|
||||
GHashTableIter object_iter;
|
||||
RegistrationData *data;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
if (g_strcmp0 (method_name, "GetManagedObjects") == 0)
|
||||
{
|
||||
@ -840,7 +840,7 @@ manager_method_call (GDBusConnection *connection,
|
||||
"Unknown method %s - only GetManagedObjects() is supported",
|
||||
method_name);
|
||||
}
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
}
|
||||
|
||||
static const GDBusInterfaceVTable manager_interface_vtable =
|
||||
@ -948,7 +948,7 @@ g_dbus_object_manager_server_get_objects (GDBusObjectManager *_manager)
|
||||
GHashTableIter iter;
|
||||
RegistrationData *data;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
|
||||
ret = NULL;
|
||||
g_hash_table_iter_init (&iter, manager->priv->map_object_path_to_data);
|
||||
@ -957,7 +957,7 @@ g_dbus_object_manager_server_get_objects (GDBusObjectManager *_manager)
|
||||
ret = g_list_prepend (ret, g_object_ref (data->object));
|
||||
}
|
||||
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -979,11 +979,11 @@ g_dbus_object_manager_server_get_object (GDBusObjectManager *_manager,
|
||||
|
||||
ret = NULL;
|
||||
|
||||
g_mutex_lock (manager->priv->lock);
|
||||
g_mutex_lock (&manager->priv->lock);
|
||||
data = g_hash_table_lookup (manager->priv->map_object_path_to_data, object_path);
|
||||
if (data != NULL)
|
||||
ret = g_object_ref (data->object);
|
||||
g_mutex_unlock (manager->priv->lock);
|
||||
g_mutex_unlock (&manager->priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
struct _GDBusObjectProxyPrivate
|
||||
{
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
GHashTable *map_name_to_iface;
|
||||
gchar *object_path;
|
||||
GDBusConnection *connection;
|
||||
@ -71,7 +71,7 @@ g_dbus_object_proxy_finalize (GObject *object)
|
||||
|
||||
g_hash_table_unref (proxy->priv->map_name_to_iface);
|
||||
|
||||
g_mutex_free (proxy->priv->lock);
|
||||
g_mutex_clear (&proxy->priv->lock);
|
||||
|
||||
if (G_OBJECT_CLASS (g_dbus_object_proxy_parent_class)->finalize != NULL)
|
||||
G_OBJECT_CLASS (g_dbus_object_proxy_parent_class)->finalize (object);
|
||||
@ -88,9 +88,9 @@ g_dbus_object_proxy_get_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_G_OBJECT_PATH:
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
g_value_set_string (value, proxy->priv->object_path);
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
break;
|
||||
|
||||
case PROP_G_CONNECTION:
|
||||
@ -114,15 +114,15 @@ g_dbus_object_proxy_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_G_OBJECT_PATH:
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
proxy->priv->object_path = g_value_dup_string (value);
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
break;
|
||||
|
||||
case PROP_G_CONNECTION:
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
proxy->priv->connection = g_value_dup_object (value);
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -183,7 +183,7 @@ g_dbus_object_proxy_init (GDBusObjectProxy *proxy)
|
||||
proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy,
|
||||
G_TYPE_DBUS_OBJECT_PROXY,
|
||||
GDBusObjectProxyPrivate);
|
||||
proxy->priv->lock = g_mutex_new ();
|
||||
g_mutex_init (&proxy->priv->lock);
|
||||
proxy->priv->map_name_to_iface = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
@ -195,9 +195,9 @@ g_dbus_object_proxy_get_object_path (GDBusObject *object)
|
||||
{
|
||||
GDBusObjectProxy *proxy = G_DBUS_OBJECT_PROXY (object);
|
||||
const gchar *ret;
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
ret = proxy->priv->object_path;
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -217,9 +217,9 @@ g_dbus_object_proxy_get_connection (GDBusObjectProxy *proxy)
|
||||
{
|
||||
GDBusConnection *ret;
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_PROXY (proxy), NULL);
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
ret = proxy->priv->connection;
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -233,11 +233,11 @@ g_dbus_object_proxy_get_interface (GDBusObject *object,
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_PROXY (proxy), NULL);
|
||||
g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
|
||||
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
ret = g_hash_table_lookup (proxy->priv->map_name_to_iface, interface_name);
|
||||
if (ret != NULL)
|
||||
g_object_ref (ret);
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
|
||||
return (GDBusInterface *) ret; /* TODO: proper cast */
|
||||
}
|
||||
@ -252,10 +252,10 @@ g_dbus_object_proxy_get_interfaces (GDBusObject *object)
|
||||
|
||||
ret = NULL;
|
||||
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
ret = g_hash_table_get_values (proxy->priv->map_name_to_iface);
|
||||
g_list_foreach (ret, (GFunc) g_object_ref, NULL);
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -296,7 +296,7 @@ _g_dbus_object_proxy_add_interface (GDBusObjectProxy *proxy,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_PROXY (proxy));
|
||||
g_return_if_fail (G_IS_DBUS_PROXY (interface_proxy));
|
||||
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
|
||||
interface_name = g_dbus_proxy_get_interface_name (interface_proxy);
|
||||
interface_proxy_to_remove = g_hash_table_lookup (proxy->priv->map_name_to_iface, interface_name);
|
||||
@ -310,7 +310,7 @@ _g_dbus_object_proxy_add_interface (GDBusObjectProxy *proxy,
|
||||
g_object_ref (interface_proxy));
|
||||
g_object_ref (interface_proxy);
|
||||
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
|
||||
if (interface_proxy_to_remove != NULL)
|
||||
{
|
||||
@ -331,20 +331,20 @@ _g_dbus_object_proxy_remove_interface (GDBusObjectProxy *proxy,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_PROXY (proxy));
|
||||
g_return_if_fail (g_dbus_is_interface_name (interface_name));
|
||||
|
||||
g_mutex_lock (proxy->priv->lock);
|
||||
g_mutex_lock (&proxy->priv->lock);
|
||||
|
||||
interface_proxy = g_hash_table_lookup (proxy->priv->map_name_to_iface, interface_name);
|
||||
if (interface_proxy != NULL)
|
||||
{
|
||||
g_object_ref (interface_proxy);
|
||||
g_warn_if_fail (g_hash_table_remove (proxy->priv->map_name_to_iface, interface_name));
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
g_signal_emit_by_name (proxy, "interface-removed", interface_proxy);
|
||||
g_object_unref (interface_proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mutex_unlock (proxy->priv->lock);
|
||||
g_mutex_unlock (&proxy->priv->lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
struct _GDBusObjectSkeletonPrivate
|
||||
{
|
||||
GMutex *lock;
|
||||
GMutex lock;
|
||||
gchar *object_path;
|
||||
GHashTable *map_name_to_iface;
|
||||
};
|
||||
@ -80,7 +80,7 @@ g_dbus_object_skeleton_finalize (GObject *_object)
|
||||
g_free (object->priv->object_path);
|
||||
g_hash_table_unref (object->priv->map_name_to_iface);
|
||||
|
||||
g_mutex_free (object->priv->lock);
|
||||
g_mutex_clear (&object->priv->lock);
|
||||
|
||||
if (G_OBJECT_CLASS (g_dbus_object_skeleton_parent_class)->finalize != NULL)
|
||||
G_OBJECT_CLASS (g_dbus_object_skeleton_parent_class)->finalize (_object);
|
||||
@ -97,9 +97,9 @@ g_dbus_object_skeleton_get_property (GObject *_object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_G_OBJECT_PATH:
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
g_value_take_string (value, object->priv->object_path);
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -204,7 +204,7 @@ static void
|
||||
g_dbus_object_skeleton_init (GDBusObjectSkeleton *object)
|
||||
{
|
||||
object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object, G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonPrivate);
|
||||
object->priv->lock = g_mutex_new ();
|
||||
g_mutex_init (&object->priv->lock);
|
||||
object->priv->map_name_to_iface = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
@ -245,18 +245,18 @@ g_dbus_object_skeleton_set_object_path (GDBusObjectSkeleton *object,
|
||||
{
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
|
||||
g_return_if_fail (object_path == NULL || g_variant_is_object_path (object_path));
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
/* TODO: fail if object is currently exported */
|
||||
if (g_strcmp0 (object->priv->object_path, object_path) != 0)
|
||||
{
|
||||
g_free (object->priv->object_path);
|
||||
object->priv->object_path = g_strdup (object_path);
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
g_object_notify (G_OBJECT (object), "g-object-path");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,9 +265,9 @@ g_dbus_object_skeleton_get_object_path (GDBusObject *_object)
|
||||
{
|
||||
GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
|
||||
const gchar *ret;
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
ret = object->priv->object_path;
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ g_dbus_object_skeleton_add_interface (GDBusObjectSkeleton *object,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
|
||||
g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
|
||||
info = g_dbus_interface_skeleton_get_info (interface_);
|
||||
g_object_ref (interface_);
|
||||
@ -312,7 +312,7 @@ g_dbus_object_skeleton_add_interface (GDBusObjectSkeleton *object,
|
||||
g_object_ref (interface_));
|
||||
g_dbus_interface_set_object (G_DBUS_INTERFACE (interface_), G_DBUS_OBJECT (object));
|
||||
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
|
||||
if (interface_to_remove != NULL)
|
||||
{
|
||||
@ -348,14 +348,14 @@ g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
|
||||
g_return_if_fail (G_IS_DBUS_INTERFACE (interface_));
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
|
||||
info = g_dbus_interface_skeleton_get_info (interface_);
|
||||
|
||||
other_interface = g_hash_table_lookup (object->priv->map_name_to_iface, info->name);
|
||||
if (other_interface == NULL)
|
||||
{
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
g_warning ("Tried to remove interface with name %s from object "
|
||||
"at path %s but no such interface exists",
|
||||
info->name,
|
||||
@ -363,7 +363,7 @@ g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object,
|
||||
}
|
||||
else if (other_interface != interface_)
|
||||
{
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
g_warning ("Tried to remove interface %p with name %s from object "
|
||||
"at path %s but the object has the interface %p",
|
||||
interface_,
|
||||
@ -375,7 +375,7 @@ g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object,
|
||||
{
|
||||
g_object_ref (interface_);
|
||||
g_warn_if_fail (g_hash_table_remove (object->priv->map_name_to_iface, info->name));
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
g_dbus_interface_set_object (G_DBUS_INTERFACE (interface_), NULL);
|
||||
g_signal_emit_by_name (object,
|
||||
"interface-removed",
|
||||
@ -406,13 +406,13 @@ g_dbus_object_skeleton_remove_interface_by_name (GDBusObjectSkeleton *object,
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
|
||||
g_return_if_fail (g_dbus_is_interface_name (interface_name));
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
interface = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name);
|
||||
if (interface != NULL)
|
||||
{
|
||||
g_object_ref (interface);
|
||||
g_warn_if_fail (g_hash_table_remove (object->priv->map_name_to_iface, interface_name));
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
g_dbus_interface_set_object (interface, NULL);
|
||||
g_signal_emit_by_name (object,
|
||||
"interface-removed",
|
||||
@ -421,7 +421,7 @@ g_dbus_object_skeleton_remove_interface_by_name (GDBusObjectSkeleton *object,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,11 +435,11 @@ g_dbus_object_skeleton_get_interface (GDBusObject *_object,
|
||||
g_return_val_if_fail (G_IS_DBUS_OBJECT_SKELETON (object), NULL);
|
||||
g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
ret = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name);
|
||||
if (ret != NULL)
|
||||
g_object_ref (ret);
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -453,10 +453,10 @@ g_dbus_object_skeleton_get_interfaces (GDBusObject *_object)
|
||||
|
||||
ret = NULL;
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
ret = g_hash_table_get_values (object->priv->map_name_to_iface);
|
||||
g_list_foreach (ret, (GFunc) g_object_ref, NULL);
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -476,10 +476,10 @@ g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object)
|
||||
{
|
||||
GList *to_flush, *l;
|
||||
|
||||
g_mutex_lock (object->priv->lock);
|
||||
g_mutex_lock (&object->priv->lock);
|
||||
to_flush = g_hash_table_get_values (object->priv->map_name_to_iface);
|
||||
g_list_foreach (to_flush, (GFunc) g_object_ref, NULL);
|
||||
g_mutex_unlock (object->priv->lock);
|
||||
g_mutex_unlock (&object->priv->lock);
|
||||
|
||||
for (l = to_flush; l != NULL; l = l->next)
|
||||
g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (l->data));
|
||||
|
@ -363,7 +363,7 @@ struct GDBusWorker
|
||||
GSocket *socket;
|
||||
|
||||
/* used for reading */
|
||||
GMutex *read_lock;
|
||||
GMutex read_lock;
|
||||
gchar *read_buffer;
|
||||
gsize read_buffer_allocated_size;
|
||||
gsize read_buffer_cur_size;
|
||||
@ -379,7 +379,7 @@ struct GDBusWorker
|
||||
*/
|
||||
gboolean output_pending;
|
||||
/* used for writing */
|
||||
GMutex *write_lock;
|
||||
GMutex write_lock;
|
||||
/* queue of MessageToWriteData, protected by write_lock */
|
||||
GQueue *write_queue;
|
||||
/* protected by write_lock */
|
||||
@ -396,8 +396,8 @@ static void _g_dbus_worker_unref (GDBusWorker *worker);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GMutex *mutex;
|
||||
GCond *cond;
|
||||
GMutex mutex;
|
||||
GCond cond;
|
||||
guint64 number_to_wait_for;
|
||||
GError *error;
|
||||
} FlushData;
|
||||
@ -451,7 +451,7 @@ _g_dbus_worker_unref (GDBusWorker *worker)
|
||||
|
||||
g_object_unref (worker->stream);
|
||||
|
||||
g_mutex_free (worker->read_lock);
|
||||
g_mutex_clear (&worker->read_lock);
|
||||
g_object_unref (worker->cancellable);
|
||||
if (worker->read_fd_list != NULL)
|
||||
g_object_unref (worker->read_fd_list);
|
||||
@ -459,7 +459,7 @@ _g_dbus_worker_unref (GDBusWorker *worker)
|
||||
g_queue_foreach (worker->received_messages_while_frozen, (GFunc) g_object_unref, NULL);
|
||||
g_queue_free (worker->received_messages_while_frozen);
|
||||
|
||||
g_mutex_free (worker->write_lock);
|
||||
g_mutex_clear (&worker->write_lock);
|
||||
g_queue_foreach (worker->write_queue, (GFunc) message_to_write_data_free, NULL);
|
||||
g_queue_free (worker->write_queue);
|
||||
|
||||
@ -523,7 +523,7 @@ unfreeze_in_idle_cb (gpointer user_data)
|
||||
GDBusWorker *worker = user_data;
|
||||
GDBusMessage *message;
|
||||
|
||||
g_mutex_lock (worker->read_lock);
|
||||
g_mutex_lock (&worker->read_lock);
|
||||
if (worker->frozen)
|
||||
{
|
||||
while ((message = g_queue_pop_head (worker->received_messages_while_frozen)) != NULL)
|
||||
@ -537,7 +537,7 @@ unfreeze_in_idle_cb (gpointer user_data)
|
||||
{
|
||||
g_assert (g_queue_get_length (worker->received_messages_while_frozen) == 0);
|
||||
}
|
||||
g_mutex_unlock (worker->read_lock);
|
||||
g_mutex_unlock (&worker->read_lock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
|
||||
GError *error;
|
||||
gssize bytes_read;
|
||||
|
||||
g_mutex_lock (worker->read_lock);
|
||||
g_mutex_lock (&worker->read_lock);
|
||||
|
||||
/* If already stopped, don't even process the reply */
|
||||
if (g_atomic_int_get (&worker->stopped))
|
||||
@ -777,7 +777,7 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
|
||||
}
|
||||
|
||||
out:
|
||||
g_mutex_unlock (worker->read_lock);
|
||||
g_mutex_unlock (&worker->read_lock);
|
||||
|
||||
/* gives up the reference acquired when calling g_input_stream_read_async() */
|
||||
_g_dbus_worker_unref (worker);
|
||||
@ -831,9 +831,9 @@ static gboolean
|
||||
_g_dbus_worker_do_initial_read (gpointer data)
|
||||
{
|
||||
GDBusWorker *worker = data;
|
||||
g_mutex_lock (worker->read_lock);
|
||||
g_mutex_lock (&worker->read_lock);
|
||||
_g_dbus_worker_do_read_unlocked (worker);
|
||||
g_mutex_unlock (worker->read_lock);
|
||||
g_mutex_unlock (&worker->read_lock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1119,9 +1119,9 @@ flush_data_list_complete (const GList *flushers,
|
||||
|
||||
f->error = error != NULL ? g_error_copy (error) : NULL;
|
||||
|
||||
g_mutex_lock (f->mutex);
|
||||
g_cond_signal (f->cond);
|
||||
g_mutex_unlock (f->mutex);
|
||||
g_mutex_lock (&f->mutex);
|
||||
g_cond_signal (&f->cond);
|
||||
g_mutex_unlock (&f->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1165,10 +1165,10 @@ ostream_flush_cb (GObject *source_object,
|
||||
|
||||
/* Make sure we tell folks that we don't have additional
|
||||
flushes pending */
|
||||
g_mutex_lock (data->worker->write_lock);
|
||||
g_mutex_lock (&data->worker->write_lock);
|
||||
g_assert (data->worker->output_pending);
|
||||
data->worker->output_pending = FALSE;
|
||||
g_mutex_unlock (data->worker->write_lock);
|
||||
g_mutex_unlock (&data->worker->write_lock);
|
||||
|
||||
/* OK, cool, finally kick off the next write */
|
||||
maybe_write_next_message (data->worker);
|
||||
@ -1213,7 +1213,7 @@ message_written (GDBusWorker *worker,
|
||||
|
||||
/* then first wake up pending flushes and, if needed, flush the stream */
|
||||
flushers = NULL;
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
worker->write_num_messages_written += 1;
|
||||
for (l = worker->write_pending_flushes; l != NULL; l = ll)
|
||||
{
|
||||
@ -1231,7 +1231,7 @@ message_written (GDBusWorker *worker,
|
||||
g_assert (!worker->output_pending);
|
||||
worker->output_pending = TRUE;
|
||||
}
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
|
||||
if (flushers != NULL)
|
||||
{
|
||||
@ -1266,10 +1266,10 @@ write_message_cb (GObject *source_object,
|
||||
MessageToWriteData *data = user_data;
|
||||
GError *error;
|
||||
|
||||
g_mutex_lock (data->worker->write_lock);
|
||||
g_mutex_lock (&data->worker->write_lock);
|
||||
g_assert (data->worker->output_pending);
|
||||
data->worker->output_pending = FALSE;
|
||||
g_mutex_unlock (data->worker->write_lock);
|
||||
g_mutex_unlock (&data->worker->write_lock);
|
||||
|
||||
error = NULL;
|
||||
if (!write_message_finish (res, &error))
|
||||
@ -1305,7 +1305,7 @@ iostream_close_cb (GObject *source_object,
|
||||
|
||||
g_io_stream_close_finish (worker->stream, res, &error);
|
||||
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
|
||||
pending_close_attempts = worker->pending_close_attempts;
|
||||
worker->pending_close_attempts = NULL;
|
||||
@ -1319,7 +1319,7 @@ iostream_close_cb (GObject *source_object,
|
||||
g_assert (worker->output_pending);
|
||||
worker->output_pending = FALSE;
|
||||
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
|
||||
while (pending_close_attempts != NULL)
|
||||
{
|
||||
@ -1372,7 +1372,7 @@ maybe_write_next_message (GDBusWorker *worker)
|
||||
/* we mustn't try to write two things at once */
|
||||
g_assert (!worker->output_pending);
|
||||
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
|
||||
/* if we want to close the connection, that takes precedence */
|
||||
if (worker->pending_close_attempts != NULL)
|
||||
@ -1392,7 +1392,7 @@ maybe_write_next_message (GDBusWorker *worker)
|
||||
worker->output_pending = TRUE;
|
||||
}
|
||||
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
|
||||
/* Note that write_lock is only used for protecting the @write_queue
|
||||
* and @output_pending fields of the GDBusWorker struct ... which we
|
||||
@ -1418,9 +1418,9 @@ maybe_write_next_message (GDBusWorker *worker)
|
||||
else if (data->message == NULL)
|
||||
{
|
||||
/* filters dropped message */
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
worker->output_pending = FALSE;
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
message_to_write_data_free (data);
|
||||
goto write_next;
|
||||
}
|
||||
@ -1490,7 +1490,7 @@ schedule_write_in_worker_thread (GDBusWorker *worker,
|
||||
MessageToWriteData *write_data,
|
||||
CloseData *close_data)
|
||||
{
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
|
||||
if (write_data != NULL)
|
||||
g_queue_push_tail (worker->write_queue, write_data);
|
||||
@ -1512,7 +1512,7 @@ schedule_write_in_worker_thread (GDBusWorker *worker,
|
||||
g_source_unref (idle_source);
|
||||
}
|
||||
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
@ -1565,7 +1565,7 @@ _g_dbus_worker_new (GIOStream *stream,
|
||||
worker = g_new0 (GDBusWorker, 1);
|
||||
worker->ref_count = 1;
|
||||
|
||||
worker->read_lock = g_mutex_new ();
|
||||
g_mutex_init (&worker->read_lock);
|
||||
worker->message_received_callback = message_received_callback;
|
||||
worker->message_about_to_be_sent_callback = message_about_to_be_sent_callback;
|
||||
worker->disconnected_callback = disconnected_callback;
|
||||
@ -1578,7 +1578,7 @@ _g_dbus_worker_new (GIOStream *stream,
|
||||
worker->frozen = initially_frozen;
|
||||
worker->received_messages_while_frozen = g_queue_new ();
|
||||
|
||||
worker->write_lock = g_mutex_new ();
|
||||
g_mutex_init (&worker->write_lock);
|
||||
worker->write_queue = g_queue_new ();
|
||||
|
||||
if (G_IS_SOCKET_CONNECTION (worker->stream))
|
||||
@ -1668,26 +1668,26 @@ _g_dbus_worker_flush_sync (GDBusWorker *worker,
|
||||
ret = TRUE;
|
||||
|
||||
/* if the queue is empty, there's nothing to wait for */
|
||||
g_mutex_lock (worker->write_lock);
|
||||
g_mutex_lock (&worker->write_lock);
|
||||
if (g_queue_get_length (worker->write_queue) > 0)
|
||||
{
|
||||
data = g_new0 (FlushData, 1);
|
||||
data->mutex = g_mutex_new ();
|
||||
data->cond = g_cond_new ();
|
||||
g_mutex_init (&data->mutex);
|
||||
g_cond_init (&data->cond);
|
||||
data->number_to_wait_for = worker->write_num_messages_written + g_queue_get_length (worker->write_queue);
|
||||
g_mutex_lock (data->mutex);
|
||||
g_mutex_lock (&data->mutex);
|
||||
worker->write_pending_flushes = g_list_prepend (worker->write_pending_flushes, data);
|
||||
}
|
||||
g_mutex_unlock (worker->write_lock);
|
||||
g_mutex_unlock (&worker->write_lock);
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
g_cond_wait (data->cond, data->mutex);
|
||||
g_mutex_unlock (data->mutex);
|
||||
g_cond_wait (&data->cond, &data->mutex);
|
||||
g_mutex_unlock (&data->mutex);
|
||||
|
||||
/* note:the element is removed from worker->write_pending_flushes in flush_cb() above */
|
||||
g_cond_free (data->cond);
|
||||
g_mutex_free (data->mutex);
|
||||
g_cond_clear (&data->cond);
|
||||
g_mutex_free (&data->mutex);
|
||||
if (data->error != NULL)
|
||||
{
|
||||
ret = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user