aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-07-01 15:01:11 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-07-01 15:18:44 +0200
commitafc7e5f9022ecec2e1ec388c9f8c48fb7c16a2b9 (patch)
tree6906659d3fdd4906ca74e8f0c24a26bb574f7c40 /libmm-glib
parent30c9fc65dacd2fb5df3913032a420e750a6ae054 (diff)
libmm-glib: use single mutex in each type to sync access
There is truly no need for a per-property mutex, using a global one for the whole object is equally fine.
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-bearer.c77
-rw-r--r--libmm-glib/mm-call.c32
-rw-r--r--libmm-glib/mm-modem-3gpp.c28
-rw-r--r--libmm-glib/mm-modem-firmware.c28
-rw-r--r--libmm-glib/mm-modem-location.c28
-rw-r--r--libmm-glib/mm-modem-messaging.c25
-rw-r--r--libmm-glib/mm-modem-oma.c25
-rw-r--r--libmm-glib/mm-modem-signal.c37
-rw-r--r--libmm-glib/mm-modem-time.c35
-rw-r--r--libmm-glib/mm-modem.c102
10 files changed, 149 insertions, 268 deletions
diff --git a/libmm-glib/mm-bearer.c b/libmm-glib/mm-bearer.c
index cc50244c..d00f1676 100644
--- a/libmm-glib/mm-bearer.c
+++ b/libmm-glib/mm-bearer.c
@@ -40,28 +40,26 @@
G_DEFINE_TYPE (MMBearer, mm_bearer, MM_GDBUS_TYPE_BEARER_PROXY)
struct _MMBearerPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* IPv4 config */
- GMutex ipv4_config_mutex;
guint ipv4_config_id;
MMBearerIpConfig *ipv4_config;
/* IPv6 config */
- GMutex ipv6_config_mutex;
guint ipv6_config_id;
MMBearerIpConfig *ipv6_config;
/* Properties */
- GMutex properties_mutex;
guint properties_id;
MMBearerProperties *properties;
/* Stats */
- GMutex stats_mutex;
guint stats_id;
MMBearerStats *stats;
/* Connection error */
- GMutex connection_error_mutex;
guint connection_error_id;
GError *connection_error;
};
@@ -296,7 +294,7 @@ static void
ipv4_config_updated (MMBearer *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->ipv4_config_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -314,14 +312,14 @@ ipv4_config_updated (MMBearer *self,
}
}
}
- g_mutex_unlock (&self->priv->ipv4_config_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_ipv4_config (MMBearer *self,
MMBearerIpConfig **dup)
{
- g_mutex_lock (&self->priv->ipv4_config_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -351,7 +349,7 @@ ensure_internal_ipv4_config (MMBearer *self,
if (dup && self->priv->ipv4_config)
*dup = g_object_ref (self->priv->ipv4_config);
}
- g_mutex_unlock (&self->priv->ipv4_config_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -414,7 +412,7 @@ static void
ipv6_config_updated (MMBearer *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->ipv6_config_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -432,14 +430,14 @@ ipv6_config_updated (MMBearer *self,
}
}
}
- g_mutex_unlock (&self->priv->ipv6_config_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_ipv6_config (MMBearer *self,
MMBearerIpConfig **dup)
{
- g_mutex_lock (&self->priv->ipv6_config_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -469,7 +467,7 @@ ensure_internal_ipv6_config (MMBearer *self,
if (dup && self->priv->ipv6_config)
*dup = g_object_ref (self->priv->ipv6_config);
}
- g_mutex_unlock (&self->priv->ipv6_config_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -532,7 +530,7 @@ static void
properties_updated (MMBearer *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->properties_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -550,14 +548,14 @@ properties_updated (MMBearer *self,
}
}
}
- g_mutex_unlock (&self->priv->properties_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_properties (MMBearer *self,
MMBearerProperties **dup)
{
- g_mutex_lock (&self->priv->properties_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -587,7 +585,7 @@ ensure_internal_properties (MMBearer *self,
if (dup && self->priv->properties)
*dup = g_object_ref (self->priv->properties);
}
- g_mutex_unlock (&self->priv->properties_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -650,7 +648,7 @@ static void
stats_updated (MMBearer *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->stats_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -667,14 +665,14 @@ stats_updated (MMBearer *self,
}
}
}
- g_mutex_unlock (&self->priv->stats_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_stats (MMBearer *self,
MMBearerStats **dup)
{
- g_mutex_lock (&self->priv->stats_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -704,7 +702,7 @@ ensure_internal_stats (MMBearer *self,
if (dup && self->priv->stats)
*dup = g_object_ref (self->priv->stats);
}
- g_mutex_unlock (&self->priv->stats_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -767,7 +765,7 @@ static void
connection_error_updated (MMBearer *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->connection_error_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *tuple;
@@ -782,14 +780,14 @@ connection_error_updated (MMBearer *self,
g_warning ("Invalid bearer connection error update received: %s", error->message);
}
}
- g_mutex_unlock (&self->priv->connection_error_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_connection_error (MMBearer *self,
GError **dup)
{
- g_mutex_lock (&self->priv->connection_error_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -816,7 +814,7 @@ ensure_internal_connection_error (MMBearer *self,
if (dup && self->priv->connection_error)
*dup = g_error_copy (self->priv->connection_error);
}
- g_mutex_unlock (&self->priv->connection_error_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -1040,15 +1038,8 @@ mm_bearer_disconnect_sync (MMBearer *self,
static void
mm_bearer_init (MMBearer *self)
{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_BEARER,
- MMBearerPrivate);
- g_mutex_init (&self->priv->ipv4_config_mutex);
- g_mutex_init (&self->priv->ipv6_config_mutex);
- g_mutex_init (&self->priv->properties_mutex);
- g_mutex_init (&self->priv->stats_mutex);
- g_mutex_init (&self->priv->connection_error_mutex);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BEARER, MMBearerPrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -1056,19 +1047,7 @@ finalize (GObject *object)
{
MMBearer *self = MM_BEARER (object);
- g_mutex_clear (&self->priv->ipv4_config_mutex);
- g_mutex_clear (&self->priv->ipv6_config_mutex);
- g_mutex_clear (&self->priv->properties_mutex);
- g_mutex_clear (&self->priv->stats_mutex);
- g_mutex_clear (&self->priv->connection_error_mutex);
-
- G_OBJECT_CLASS (mm_bearer_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMBearer *self = MM_BEARER (object);
+ g_mutex_clear (&self->priv->mutex);
g_clear_object (&self->priv->ipv4_config);
g_clear_object (&self->priv->ipv6_config);
@@ -1076,7 +1055,7 @@ dispose (GObject *object)
g_clear_object (&self->priv->stats);
g_clear_error (&self->priv->connection_error);
- G_OBJECT_CLASS (mm_bearer_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_bearer_parent_class)->finalize (object);
}
static void
@@ -1086,7 +1065,5 @@ mm_bearer_class_init (MMBearerClass *bearer_class)
g_type_class_add_private (object_class, sizeof (MMBearerPrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-call.c b/libmm-glib/mm-call.c
index 46edfd6f..f9f45fca 100644
--- a/libmm-glib/mm-call.c
+++ b/libmm-glib/mm-call.c
@@ -37,8 +37,10 @@
G_DEFINE_TYPE (MMCall, mm_call, MM_GDBUS_TYPE_CALL_PROXY)
struct _MMCallPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Audio Format */
- GMutex audio_format_mutex;
guint audio_format_id;
MMCallAudioFormat *audio_format;
};
@@ -265,7 +267,7 @@ static void
audio_format_updated (MMCall *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->audio_format_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -283,14 +285,14 @@ audio_format_updated (MMCall *self,
}
}
}
- g_mutex_unlock (&self->priv->audio_format_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_audio_format (MMCall *self,
MMCallAudioFormat **dup)
{
- g_mutex_lock (&self->priv->audio_format_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -320,7 +322,7 @@ ensure_internal_audio_format (MMCall *self,
if (dup && self->priv->audio_format)
*dup = g_object_ref (self->priv->audio_format);
}
- g_mutex_unlock (&self->priv->audio_format_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -1013,10 +1015,8 @@ mm_call_send_dtmf_sync (MMCall *self,
static void
mm_call_init (MMCall *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_CALL,
- MMCallPrivate);
- g_mutex_init (&self->priv->audio_format_mutex);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_CALL, MMCallPrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -1024,19 +1024,11 @@ finalize (GObject *object)
{
MMCall *self = MM_CALL (object);
- g_mutex_clear (&self->priv->audio_format_mutex);
-
- G_OBJECT_CLASS (mm_call_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMCall *self = MM_CALL (object);
+ g_mutex_clear (&self->priv->mutex);
g_clear_object (&self->priv->audio_format);
- G_OBJECT_CLASS (mm_call_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_call_parent_class)->finalize (object);
}
static void
@@ -1046,7 +1038,5 @@ mm_call_class_init (MMCallClass *call_class)
g_type_class_add_private (object_class, sizeof (MMCallPrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-3gpp.c b/libmm-glib/mm-modem-3gpp.c
index 6fefc952..6980dff7 100644
--- a/libmm-glib/mm-modem-3gpp.c
+++ b/libmm-glib/mm-modem-3gpp.c
@@ -45,8 +45,10 @@
G_DEFINE_TYPE (MMModem3gpp, mm_modem_3gpp, MM_GDBUS_TYPE_MODEM3GPP_PROXY)
struct _MMModem3gppPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Properties */
- GMutex initial_eps_bearer_settings_mutex;
guint initial_eps_bearer_settings_id;
MMBearerProperties *initial_eps_bearer_settings;
};
@@ -632,7 +634,7 @@ static void
initial_eps_bearer_settings_updated (MMModem3gpp *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->initial_eps_bearer_settings_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -649,14 +651,14 @@ initial_eps_bearer_settings_updated (MMModem3gpp *self,
}
}
}
- g_mutex_unlock (&self->priv->initial_eps_bearer_settings_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_initial_eps_bearer_settings (MMModem3gpp *self,
MMBearerProperties **dup)
{
- g_mutex_lock (&self->priv->initial_eps_bearer_settings_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -686,7 +688,7 @@ ensure_internal_initial_eps_bearer_settings (MMModem3gpp *self,
if (dup && self->priv->initial_eps_bearer_settings)
*dup = g_object_ref (self->priv->initial_eps_bearer_settings);
}
- g_mutex_unlock (&self->priv->initial_eps_bearer_settings_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -1283,7 +1285,7 @@ static void
mm_modem_3gpp_init (MMModem3gpp *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_3GPP, MMModem3gppPrivate);
- g_mutex_init (&self->priv->initial_eps_bearer_settings_mutex);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -1291,19 +1293,11 @@ finalize (GObject *object)
{
MMModem3gpp *self = MM_MODEM_3GPP (object);
- g_mutex_clear (&self->priv->initial_eps_bearer_settings_mutex);
-
- G_OBJECT_CLASS (mm_modem_3gpp_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMModem3gpp *self = MM_MODEM_3GPP (object);
+ g_mutex_clear (&self->priv->mutex);
g_clear_object (&self->priv->initial_eps_bearer_settings);
- G_OBJECT_CLASS (mm_modem_3gpp_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_modem_3gpp_parent_class)->finalize (object);
}
static void
@@ -1313,7 +1307,5 @@ mm_modem_3gpp_class_init (MMModem3gppClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModem3gppPrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-firmware.c b/libmm-glib/mm-modem-firmware.c
index 593fb7ab..1aca87c8 100644
--- a/libmm-glib/mm-modem-firmware.c
+++ b/libmm-glib/mm-modem-firmware.c
@@ -41,7 +41,9 @@
G_DEFINE_TYPE (MMModemFirmware, mm_modem_firmware, MM_GDBUS_TYPE_MODEM_FIRMWARE_PROXY)
struct _MMModemFirmwarePrivate {
- GMutex update_settings_mutex;
+ /* Common mutex to sync access */
+ GMutex mutex;
+
guint update_settings_id;
MMFirmwareUpdateSettings *update_settings;
};
@@ -98,7 +100,7 @@ static void
update_settings_updated (MMModemFirmware *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->update_settings_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *variant;
@@ -114,14 +116,14 @@ update_settings_updated (MMModemFirmware *self,
}
}
}
- g_mutex_unlock (&self->priv->update_settings_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_update_settings (MMModemFirmware *self,
MMFirmwareUpdateSettings **dupl)
{
- g_mutex_lock (&self->priv->update_settings_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -151,7 +153,7 @@ ensure_internal_update_settings (MMModemFirmware *self,
if (dupl && self->priv->update_settings)
*dupl = g_object_ref (self->priv->update_settings);
}
- g_mutex_unlock (&self->priv->update_settings_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -533,7 +535,7 @@ static void
mm_modem_firmware_init (MMModemFirmware *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_FIRMWARE, MMModemFirmwarePrivate);
- g_mutex_init (&self->priv->update_settings_mutex);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -541,19 +543,11 @@ finalize (GObject *object)
{
MMModemFirmware *self = MM_MODEM_FIRMWARE (object);
- g_mutex_clear (&self->priv->update_settings_mutex);
-
- G_OBJECT_CLASS (mm_modem_firmware_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMModemFirmware *self = MM_MODEM_FIRMWARE (object);
+ g_mutex_clear (&self->priv->mutex);
g_clear_object (&self->priv->update_settings);
- G_OBJECT_CLASS (mm_modem_firmware_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_modem_firmware_parent_class)->finalize (object);
}
static void
@@ -563,7 +557,5 @@ mm_modem_firmware_class_init (MMModemFirmwareClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemFirmwarePrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-location.c b/libmm-glib/mm-modem-location.c
index 06aafdde..47e4ec12 100644
--- a/libmm-glib/mm-modem-location.c
+++ b/libmm-glib/mm-modem-location.c
@@ -41,7 +41,9 @@
G_DEFINE_TYPE (MMModemLocation, mm_modem_location, MM_GDBUS_TYPE_MODEM_LOCATION_PROXY)
struct _MMModemLocationPrivate {
- GMutex signaled_location_mutex;
+ /* Common mutex to sync access */
+ GMutex mutex;
+
guint signaled_location_id;
MMLocation3gpp *signaled_location_3gpp;
MMLocationGpsNmea *signaled_location_gps_nmea;
@@ -1219,7 +1221,7 @@ static void
signaled_location_updated (MMModemLocation *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->signaled_location_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1241,7 +1243,7 @@ signaled_location_updated (MMModemLocation *self,
g_warning ("Invalid signaled location received: %s", error->message);
}
}
- g_mutex_unlock (&self->priv->signaled_location_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
@@ -1251,7 +1253,7 @@ ensure_internal_signaled_location (MMModemLocation *self,
MMLocationGpsRaw **dupl_location_gps_raw,
MMLocationCdmaBs **dupl_location_cdma_bs)
{
- g_mutex_lock (&self->priv->signaled_location_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -1288,7 +1290,7 @@ ensure_internal_signaled_location (MMModemLocation *self,
if (dupl_location_cdma_bs && self->priv->signaled_location_cdma_bs)
*dupl_location_cdma_bs = g_object_ref (self->priv->signaled_location_cdma_bs);
}
- g_mutex_unlock (&self->priv->signaled_location_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -1565,7 +1567,7 @@ static void
mm_modem_location_init (MMModemLocation *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_LOCATION, MMModemLocationPrivate);
- g_mutex_init (&self->priv->signaled_location_mutex);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -1573,22 +1575,14 @@ finalize (GObject *object)
{
MMModemLocation *self = MM_MODEM_LOCATION (object);
- g_mutex_clear (&self->priv->signaled_location_mutex);
-
- G_OBJECT_CLASS (mm_modem_location_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMModemLocation *self = MM_MODEM_LOCATION (object);
+ g_mutex_clear (&self->priv->mutex);
g_clear_object (&self->priv->signaled_location_3gpp);
g_clear_object (&self->priv->signaled_location_gps_nmea);
g_clear_object (&self->priv->signaled_location_gps_raw);
g_clear_object (&self->priv->signaled_location_cdma_bs);
- G_OBJECT_CLASS (mm_modem_location_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_modem_location_parent_class)->finalize (object);
}
static void
@@ -1598,7 +1592,5 @@ mm_modem_location_class_init (MMModemLocationClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemLocationPrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-messaging.c b/libmm-glib/mm-modem-messaging.c
index 2f23f8a1..ed4cb2e7 100644
--- a/libmm-glib/mm-modem-messaging.c
+++ b/libmm-glib/mm-modem-messaging.c
@@ -42,8 +42,10 @@
G_DEFINE_TYPE (MMModemMessaging, mm_modem_messaging, MM_GDBUS_TYPE_MODEM_MESSAGING_PROXY)
struct _MMModemMessagingPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Supported Storage */
- GMutex supported_storages_mutex;
guint supported_storages_id;
GArray *supported_storages;
};
@@ -100,7 +102,7 @@ static void
supported_storages_updated (MMModemMessaging *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->supported_storages_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -112,7 +114,7 @@ supported_storages_updated (MMModemMessaging *self,
mm_common_sms_storages_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->supported_storages_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -122,7 +124,7 @@ ensure_internal_supported_storages (MMModemMessaging *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->supported_storages_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -158,7 +160,7 @@ ensure_internal_supported_storages (MMModemMessaging *self,
}
}
}
- g_mutex_unlock (&self->priv->supported_storages_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -734,11 +736,8 @@ mm_modem_messaging_delete_sync (MMModemMessaging *self,
static void
mm_modem_messaging_init (MMModemMessaging *self)
{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_MODEM_MESSAGING,
- MMModemMessagingPrivate);
- g_mutex_init (&self->priv->supported_storages_mutex);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_MESSAGING, MMModemMessagingPrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -746,10 +745,9 @@ finalize (GObject *object)
{
MMModemMessaging *self = MM_MODEM_MESSAGING (object);
- g_mutex_clear (&self->priv->supported_storages_mutex);
+ g_mutex_clear (&self->priv->mutex);
- if (self->priv->supported_storages)
- g_array_unref (self->priv->supported_storages);
+ g_clear_pointer (&self->priv->supported_storages, g_array_unref);
G_OBJECT_CLASS (mm_modem_messaging_parent_class)->finalize (object);
}
@@ -761,6 +759,5 @@ mm_modem_messaging_class_init (MMModemMessagingClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemMessagingPrivate));
- /* Virtual methods */
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-oma.c b/libmm-glib/mm-modem-oma.c
index 72f57dd7..9ee55a4f 100644
--- a/libmm-glib/mm-modem-oma.c
+++ b/libmm-glib/mm-modem-oma.c
@@ -43,8 +43,10 @@
G_DEFINE_TYPE (MMModemOma, mm_modem_oma, MM_GDBUS_TYPE_MODEM_OMA_PROXY)
struct _MMModemOmaPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Supported Modes */
- GMutex pending_network_initiated_sessions_mutex;
guint pending_network_initiated_sessions_id;
GArray *pending_network_initiated_sessions;
};
@@ -507,7 +509,7 @@ static void
pending_network_initiated_sessions_updated (MMModemOma *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->pending_network_initiated_sessions_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -519,7 +521,7 @@ pending_network_initiated_sessions_updated (MMModemOma *self,
mm_common_oma_pending_network_initiated_sessions_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->pending_network_initiated_sessions_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -529,7 +531,7 @@ ensure_internal_pending_network_initiated_sessions (MMModemOma *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->pending_network_initiated_sessions_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -565,7 +567,7 @@ ensure_internal_pending_network_initiated_sessions (MMModemOma *self,
}
}
}
- g_mutex_unlock (&self->priv->pending_network_initiated_sessions_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -632,11 +634,8 @@ mm_modem_oma_peek_pending_network_initiated_sessions (MMModemOma
static void
mm_modem_oma_init (MMModemOma *self)
{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_MODEM_OMA,
- MMModemOmaPrivate);
- g_mutex_init (&self->priv->pending_network_initiated_sessions_mutex);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_OMA, MMModemOmaPrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -644,10 +643,9 @@ finalize (GObject *object)
{
MMModemOma *self = MM_MODEM_OMA (object);
- g_mutex_clear (&self->priv->pending_network_initiated_sessions_mutex);
+ g_mutex_clear (&self->priv->mutex);
- if (self->priv->pending_network_initiated_sessions)
- g_array_unref (self->priv->pending_network_initiated_sessions);
+ g_clear_pointer (&self->priv->pending_network_initiated_sessions, g_array_unref);
G_OBJECT_CLASS (mm_modem_oma_parent_class)->finalize (object);
}
@@ -659,6 +657,5 @@ mm_modem_oma_class_init (MMModemOmaClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemOmaPrivate));
- /* Virtual methods */
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-signal.c b/libmm-glib/mm-modem-signal.c
index 0b740c72..c511b1d8 100644
--- a/libmm-glib/mm-modem-signal.c
+++ b/libmm-glib/mm-modem-signal.c
@@ -42,8 +42,7 @@
G_DEFINE_TYPE (MMModemSignal, mm_modem_signal, MM_GDBUS_TYPE_MODEM_SIGNAL_PROXY)
typedef struct {
- GMutex mutex;
- guint id;
+ guint id;
MMSignal *info;
} UpdatedProperty;
@@ -58,6 +57,9 @@ typedef enum {
} UpdatedPropertyType;
struct _MMModemSignalPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
UpdatedProperty values [UPDATED_PROPERTY_TYPE_LAST];
};
@@ -282,7 +284,7 @@ values_updated (MMModemSignal *self,
GParamSpec *pspec,
UpdatedPropertyType type)
{
- g_mutex_lock (&self->priv->values[type].mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -298,7 +300,7 @@ values_updated (MMModemSignal *self,
}
}
}
- g_mutex_unlock (&self->priv->values[type].mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
@@ -306,7 +308,7 @@ ensure_internal (MMModemSignal *self,
MMSignal **dup,
UpdatedPropertyType type)
{
- g_mutex_lock (&self->priv->values[type].mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -336,7 +338,7 @@ ensure_internal (MMModemSignal *self,
if (dup && self->priv->values[type].info)
*dup = g_object_ref (self->priv->values[type].info);
}
- g_mutex_unlock (&self->priv->values[type].mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/*****************************************************************************/
@@ -660,13 +662,8 @@ mm_modem_signal_peek_nr5g (MMModemSignal *self)
static void
mm_modem_signal_init (MMModemSignal *self)
{
- guint i;
-
- /* Setup private data */
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_SIGNAL, MMModemSignalPrivate);
-
- for (i = 0; i < UPDATED_PROPERTY_TYPE_LAST; i++)
- g_mutex_init (&self->priv->values[i].mutex);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -675,22 +672,12 @@ finalize (GObject *object)
MMModemSignal *self = MM_MODEM_SIGNAL (object);
guint i;
- for (i = 0; i < UPDATED_PROPERTY_TYPE_LAST; i++)
- g_mutex_clear (&self->priv->values[i].mutex);
-
- G_OBJECT_CLASS (mm_modem_signal_parent_class)->finalize (object);
-}
-
-static void
-dispose (GObject *object)
-{
- MMModemSignal *self = MM_MODEM_SIGNAL (object);
- guint i;
+ g_mutex_clear (&self->priv->mutex);
for (i = 0; i < UPDATED_PROPERTY_TYPE_LAST; i++)
g_clear_object (&self->priv->values[i].info);
- G_OBJECT_CLASS (mm_modem_signal_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_modem_signal_parent_class)->finalize (object);
}
static void
@@ -700,7 +687,5 @@ mm_modem_signal_class_init (MMModemSignalClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemSignalPrivate));
- /* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}
diff --git a/libmm-glib/mm-modem-time.c b/libmm-glib/mm-modem-time.c
index 6cc8a74d..47ca92f7 100644
--- a/libmm-glib/mm-modem-time.c
+++ b/libmm-glib/mm-modem-time.c
@@ -41,8 +41,10 @@
G_DEFINE_TYPE (MMModemTime, mm_modem_time, MM_GDBUS_TYPE_MODEM_TIME_PROXY)
struct _MMModemTimePrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Timezone */
- GMutex timezone_mutex;
guint timezone_id;
MMNetworkTimezone *timezone;
};
@@ -195,7 +197,7 @@ static void
timezone_updated (MMModemTime *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->timezone_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -205,14 +207,14 @@ timezone_updated (MMModemTime *self,
mm_network_timezone_new_from_dictionary (dictionary, NULL) :
NULL);
}
- g_mutex_unlock (&self->priv->timezone_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_timezone (MMModemTime *self,
MMNetworkTimezone **dup)
{
- g_mutex_lock (&self->priv->timezone_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -236,7 +238,7 @@ ensure_internal_timezone (MMModemTime *self,
if (dup && self->priv->timezone)
*dup = g_object_ref (self->priv->timezone);
}
- g_mutex_unlock (&self->priv->timezone_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -295,21 +297,8 @@ mm_modem_time_peek_network_timezone (MMModemTime *self)
static void
mm_modem_time_init (MMModemTime *self)
{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_MODEM_TIME,
- MMModemTimePrivate);
- g_mutex_init (&self->priv->timezone_mutex);
-}
-
-static void
-dispose (GObject *object)
-{
- MMModemTime *self = MM_MODEM_TIME (object);
-
- g_clear_object (&self->priv->timezone);
-
- G_OBJECT_CLASS (mm_modem_time_parent_class)->dispose (object);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_TIME, MMModemTimePrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -317,7 +306,9 @@ finalize (GObject *object)
{
MMModemTime *self = MM_MODEM_TIME (object);
- g_mutex_clear (&self->priv->timezone_mutex);
+ g_mutex_clear (&self->priv->mutex);
+
+ g_clear_object (&self->priv->timezone);
G_OBJECT_CLASS (mm_modem_time_parent_class)->finalize (object);
}
@@ -329,7 +320,5 @@ mm_modem_time_class_init (MMModemTimeClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemTimePrivate));
- /* Virtual methods */
object_class->finalize = finalize;
- object_class->dispose = dispose;
}
diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c
index d117e856..e2fd5cd0 100644
--- a/libmm-glib/mm-modem.c
+++ b/libmm-glib/mm-modem.c
@@ -44,33 +44,30 @@
G_DEFINE_TYPE (MMModem, mm_modem, MM_GDBUS_TYPE_MODEM_PROXY)
struct _MMModemPrivate {
+ /* Common mutex to sync access */
+ GMutex mutex;
+
/* Ports */
- GMutex ports_mutex;
guint ports_id;
GArray *ports;
/* UnlockRetries */
- GMutex unlock_retries_mutex;
guint unlock_retries_id;
MMUnlockRetries *unlock_retries;
/* Supported Modes */
- GMutex supported_modes_mutex;
guint supported_modes_id;
GArray *supported_modes;
/* Supported Capabilities */
- GMutex supported_capabilities_mutex;
guint supported_capabilities_id;
GArray *supported_capabilities;
/* Supported Bands */
- GMutex supported_bands_mutex;
guint supported_bands_id;
GArray *supported_bands;
/* Current Bands */
- GMutex current_bands_mutex;
guint current_bands_id;
GArray *current_bands;
};
@@ -248,7 +245,7 @@ static void
supported_capabilities_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->supported_capabilities_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -260,7 +257,7 @@ supported_capabilities_updated (MMModem *self,
mm_common_capability_combinations_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->supported_capabilities_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -270,7 +267,7 @@ ensure_internal_supported_capabilities (MMModem *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->supported_capabilities_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -306,7 +303,7 @@ ensure_internal_supported_capabilities (MMModem *self,
}
}
}
- g_mutex_unlock (&self->priv->supported_capabilities_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -1026,7 +1023,7 @@ static void
ports_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->ports_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1038,7 +1035,7 @@ ports_updated (MMModem *self,
mm_common_ports_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->ports_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -1049,7 +1046,7 @@ ensure_internal_ports (MMModem *self,
gboolean ret;
guint i;
- g_mutex_lock (&self->priv->ports_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -1093,7 +1090,7 @@ ensure_internal_ports (MMModem *self,
}
}
}
- g_mutex_unlock (&self->priv->ports_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -1290,7 +1287,7 @@ static void
unlock_retries_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->unlock_retries_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1301,14 +1298,14 @@ unlock_retries_updated (MMModem *self,
if (dictionary)
self->priv->unlock_retries = mm_unlock_retries_new_from_dictionary (dictionary);
}
- g_mutex_unlock (&self->priv->unlock_retries_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static void
ensure_internal_unlock_retries (MMModem *self,
MMUnlockRetries **dup)
{
- g_mutex_lock (&self->priv->unlock_retries_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
@@ -1332,7 +1329,7 @@ ensure_internal_unlock_retries (MMModem *self,
if (dup && self->priv->unlock_retries)
*dup = g_object_ref (self->priv->unlock_retries);
}
- g_mutex_unlock (&self->priv->unlock_retries_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
/**
@@ -1520,7 +1517,7 @@ static void
supported_modes_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->supported_modes_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1532,7 +1529,7 @@ supported_modes_updated (MMModem *self,
mm_common_mode_combinations_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->supported_modes_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -1542,7 +1539,7 @@ ensure_internal_supported_modes (MMModem *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->supported_modes_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -1578,7 +1575,7 @@ ensure_internal_supported_modes (MMModem *self,
}
}
}
- g_mutex_unlock (&self->priv->supported_modes_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -1686,7 +1683,7 @@ static void
supported_bands_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->supported_bands_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1698,7 +1695,7 @@ supported_bands_updated (MMModem *self,
mm_common_bands_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->supported_bands_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -1708,7 +1705,7 @@ ensure_internal_supported_bands (MMModem *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->supported_bands_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -1744,7 +1741,7 @@ ensure_internal_supported_bands (MMModem *self,
}
}
}
- g_mutex_unlock (&self->priv->supported_bands_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -1817,7 +1814,7 @@ static void
current_bands_updated (MMModem *self,
GParamSpec *pspec)
{
- g_mutex_lock (&self->priv->current_bands_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
GVariant *dictionary;
@@ -1829,7 +1826,7 @@ current_bands_updated (MMModem *self,
mm_common_bands_variant_to_garray (dictionary) :
NULL);
}
- g_mutex_unlock (&self->priv->current_bands_mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
static gboolean
@@ -1839,7 +1836,7 @@ ensure_internal_current_bands (MMModem *self,
{
gboolean ret;
- g_mutex_lock (&self->priv->current_bands_mutex);
+ g_mutex_lock (&self->priv->mutex);
{
/* If this is the first time ever asking for the array, setup the
* update listener and the initial array, if any. */
@@ -1875,7 +1872,7 @@ ensure_internal_current_bands (MMModem *self,
}
}
}
- g_mutex_unlock (&self->priv->current_bands_mutex);
+ g_mutex_unlock (&self->priv->mutex);
return ret;
}
@@ -3782,16 +3779,8 @@ mm_modem_set_primary_sim_slot_sync (MMModem *self,
static void
mm_modem_init (MMModem *self)
{
- /* Setup private data */
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- MM_TYPE_MODEM,
- MMModemPrivate);
- g_mutex_init (&self->priv->unlock_retries_mutex);
- g_mutex_init (&self->priv->supported_modes_mutex);
- g_mutex_init (&self->priv->supported_capabilities_mutex);
- g_mutex_init (&self->priv->supported_bands_mutex);
- g_mutex_init (&self->priv->current_bands_mutex);
- g_mutex_init (&self->priv->ports_mutex);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM, MMModemPrivate);
+ g_mutex_init (&self->priv->mutex);
}
static void
@@ -3799,35 +3788,17 @@ finalize (GObject *object)
{
MMModem *self = MM_MODEM (object);
- g_mutex_clear (&self->priv->unlock_retries_mutex);
- g_mutex_clear (&self->priv->supported_modes_mutex);
- g_mutex_clear (&self->priv->supported_capabilities_mutex);
- g_mutex_clear (&self->priv->supported_bands_mutex);
- g_mutex_clear (&self->priv->current_bands_mutex);
- g_mutex_clear (&self->priv->ports_mutex);
-
- if (self->priv->supported_modes)
- g_array_unref (self->priv->supported_modes);
- if (self->priv->supported_capabilities)
- g_array_unref (self->priv->supported_capabilities);
- if (self->priv->supported_bands)
- g_array_unref (self->priv->supported_bands);
- if (self->priv->current_bands)
- g_array_unref (self->priv->current_bands);
- if (self->priv->ports)
- g_array_unref (self->priv->ports);
-
- G_OBJECT_CLASS (mm_modem_parent_class)->finalize (object);
-}
+ g_mutex_clear (&self->priv->mutex);
-static void
-dispose (GObject *object)
-{
- MMModem *self = MM_MODEM (object);
+ g_clear_pointer (&self->priv->supported_modes, g_array_unref);
+ g_clear_pointer (&self->priv->supported_capabilities, g_array_unref);
+ g_clear_pointer (&self->priv->supported_bands, g_array_unref);
+ g_clear_pointer (&self->priv->current_bands, g_array_unref);
+ g_clear_pointer (&self->priv->ports, g_array_unref);
g_clear_object (&self->priv->unlock_retries);
- G_OBJECT_CLASS (mm_modem_parent_class)->dispose (object);
+ G_OBJECT_CLASS (mm_modem_parent_class)->finalize (object);
}
static void
@@ -3838,6 +3809,5 @@ mm_modem_class_init (MMModemClass *modem_class)
g_type_class_add_private (object_class, sizeof (MMModemPrivate));
/* Virtual methods */
- object_class->dispose = dispose;
object_class->finalize = finalize;
}