summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-08-07 16:12:55 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-08-07 16:14:49 -0500
commitebce9fbd4d4992cfe1129c98c8067f8a94849246 (patch)
treec4979da0e13048247470ffd7fae237936d1feba9
parent44e56bf752338ae62c3e20c2576461886ff9a8d0 (diff)
downloadofono-ebce9fbd4d4992cfe1129c98c8067f8a94849246.tar.bz2
Store the tx_next g_source so it can be removed
-rw-r--r--src/sms.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sms.c b/src/sms.c
index 85f11469..c7d83fa8 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -54,6 +54,7 @@ struct sms_manager_data {
guint ref;
GQueue *txq;
time_t last_mms;
+ gint tx_source;
};
struct pending_pdu {
@@ -82,6 +83,11 @@ static void sms_manager_destroy(gpointer userdata)
struct ofono_modem *modem = userdata;
struct sms_manager_data *data = modem->sms_manager;
+ if (data->tx_source) {
+ g_source_remove(data->tx_source);
+ data->tx_source = 0;
+ }
+
if (data->assembly) {
sms_assembly_free(data->assembly);
data->assembly = NULL;
@@ -291,7 +297,7 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
ofono_debug("Sending failed, retrying in 5 seconds...");
- g_timeout_add_seconds(5, tx_next, modem);
+ sms->tx_source = g_timeout_add_seconds(5, tx_next, modem);
return;
}
@@ -302,7 +308,7 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
if (g_queue_peek_head(sms->txq)) {
ofono_debug("Scheduling next");
- g_timeout_add(0, tx_next, modem);
+ sms->tx_source = g_timeout_add(0, tx_next, modem);
}
}
@@ -319,6 +325,8 @@ static gboolean tx_next(gpointer user_data)
ofono_debug("tx_next: %p", pdu);
+ sms->tx_source = 0;
+
if (!pdu)
return FALSE;
@@ -377,7 +385,7 @@ static void append_tx_queue(struct ofono_modem *modem, GSList *msg_list)
}
if (start)
- g_timeout_add(0, tx_next, modem);
+ sms->tx_source = g_timeout_add(0, tx_next, modem);
}
static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,