summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2009-08-06 22:29:12 +0200
committerDenis Kenzior <denkenz@gmail.com>2009-08-07 15:49:30 -0500
commitd6aae609834895ed92ebd406cbfb27e7e0d045b3 (patch)
tree56440d4d595e55d2cd7454305983c174de36dc09
parent2520e2682078d801d13dfac8a1ef467649e71cc3 (diff)
downloadofono-d6aae609834895ed92ebd406cbfb27e7e0d045b3.tar.bz2
Make SIM op queue more robust.
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.
-rw-r--r--src/sim.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sim.c b/src/sim.c
index 33764623..b7832f56 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)