All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Reorder statements to make SIM op queue more robust.
@ 2009-08-06 20:29 Andrzej Zaborowski
  2009-08-07 20:50 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Andrzej Zaborowski @ 2009-08-06 20:29 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

This allows ofono_sim_read and ofono_sim_write callbacks to queue new
read or write operations.  The callback must not be called between
removing the operation from queue and checking queue length.
---
 src/sim.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 3376462..b7832f5 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -304,6 +304,9 @@ static void sim_op_error(struct ofono_modem *modem)
 	struct sim_manager_data *sim = modem->sim_manager;
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
 
+	if (g_queue_get_length(sim->simop_q) > 0)
+		g_timeout_add(0, sim_op_next, modem);
+
 	if (op->is_read == TRUE)
 		((ofono_sim_file_read_cb_t) op->cb)
 			(modem, 0, 0, 0, 0, 0, 0, op->userdata);
@@ -312,9 +315,6 @@ static void sim_op_error(struct ofono_modem *modem)
 			(modem, 0, op->userdata);
 
 	sim_file_op_free(op);
-
-	if (g_queue_get_length(sim->simop_q) > 0)
-		g_timeout_add(0, sim_op_next, modem);
 }
 
 static gboolean cache_record(const char *path, int current, int record_len,
@@ -517,15 +517,15 @@ static void sim_op_write_cb(const struct ofono_error *error, void *data)
 	struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
 	ofono_sim_file_write_cb_t cb = op->cb;
 
+	if (g_queue_get_length(sim->simop_q) > 0)
+		g_timeout_add(0, sim_op_next, modem);
+
 	if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
 		cb(modem, 1, op->userdata);
 	else
 		cb(modem, 0, op->userdata);
 
 	sim_file_op_free(op);
-
-	if (g_queue_get_length(sim->simop_q) > 0)
-		g_timeout_add(0, sim_op_next, modem);
 }
 
 static gboolean sim_op_next(gpointer user_data)
-- 
1.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-07 20:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 20:29 [PATCH] Reorder statements to make SIM op queue more robust Andrzej Zaborowski
2009-08-07 20:50 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.