aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-generic-gsm.c1
-rw-r--r--src/mm-serial.c24
2 files changed, 22 insertions, 3 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 541c9a57..f2b1d040 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -462,7 +462,6 @@ get_reg_status_done (MMSerial *serial,
static void
get_registration_status (MMSerial *serial, MMCallbackInfo *info)
{
- g_debug ("Queueing +CREG");
mm_serial_queue_command (serial, "+CREG?", 3, get_reg_status_done, info);
}
diff --git a/src/mm-serial.c b/src/mm-serial.c
index 02869bff..415a3e2d 100644
--- a/src/mm-serial.c
+++ b/src/mm-serial.c
@@ -58,6 +58,7 @@ typedef struct {
guint stopbits;
guint64 send_delay;
+ guint queue_schedule;
guint watch_id;
guint timeout_id;
} MMSerialPrivate;
@@ -324,6 +325,23 @@ typedef struct {
} MMQueueData;
static void
+mm_serial_schedule_queue_process (MMSerial *self)
+{
+ MMSerialPrivate *priv = MM_SERIAL_GET_PRIVATE (self);
+ GSource *source;
+
+ if (priv->queue_schedule)
+ /* Already scheduled */
+ return;
+
+ source = g_idle_source_new ();
+ g_source_set_closure (source, g_cclosure_new_object (G_CALLBACK (mm_serial_queue_process), G_OBJECT (self)));
+ g_source_attach (source, NULL);
+ priv->queue_schedule = g_source_get_id (source);
+ g_source_unref (source);
+}
+
+static void
mm_serial_got_response (MMSerial *self, GError *error)
{
MMSerialPrivate *priv = MM_SERIAL_GET_PRIVATE (self);
@@ -346,7 +364,7 @@ mm_serial_got_response (MMSerial *self, GError *error)
g_string_truncate (priv->response, 0);
if (!g_queue_is_empty (priv->queue))
- g_idle_add (mm_serial_queue_process, self);
+ mm_serial_schedule_queue_process (self);
}
static gboolean
@@ -377,6 +395,8 @@ mm_serial_queue_process (gpointer data)
MMQueueData *info;
GError *error = NULL;
+ priv->queue_schedule = 0;
+
info = (MMQueueData *) g_queue_peek_head (priv->queue);
if (!info)
return FALSE;
@@ -557,7 +577,7 @@ mm_serial_queue_command (MMSerial *self,
g_queue_push_tail (priv->queue, info);
if (g_queue_get_length (priv->queue) == 1)
- g_idle_add (mm_serial_queue_process, self);
+ mm_serial_schedule_queue_process (self);
}
typedef struct {