Fix: Sometimes it is possible to cancel first cmd
authorDenis Kenzior <denkenz@gmail.com>
Wed, 2 Dec 2009 21:27:26 +0000 (15:27 -0600)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Dec 2009 01:16:21 +0000 (02:16 +0100)
Commands on the head of the queue can be canceled if none of its bytes
have actually been written to the modem.  This is tracked by
cmd_bytes_written variable.

gatchat/gatchat.c

index 1dffd89..df65906 100644 (file)
@@ -1202,7 +1202,8 @@ gboolean g_at_chat_cancel(GAtChat *chat, guint id)
        if (!l)
                return FALSE;
 
-       if (l == g_queue_peek_head(chat->command_queue)) {
+       if (l == g_queue_peek_head(chat->command_queue) &&
+                       chat->cmd_bytes_written > 0) {
                struct at_command *c = l->data;
 
                /* We can't actually remove it since it is most likely