---
 gatchat/gatserver.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index fdc4180..5d2a036 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -118,6 +118,7 @@ struct _GAtServer {
        unsigned int read_pos;                  /* Current read offset */
        int notify_source;                      /* Source of notify callback */
        GAtServerResult last_result;            /* Result of last command */
+       gboolean is_online;                     /* Online or offline mode */
 };
 
 struct at_notify_node {
@@ -239,6 +240,8 @@ static void g_at_server_send_flush(GAtServer *server)
                sprintf(buf, "%u", (unsigned int)result);
 
        send_result_common(server, buf);
+
+       server->is_online = TRUE;
 }
 
 inline void g_at_server_send_final(GAtServer *server, GAtServerResult result)
@@ -728,7 +731,7 @@ static void new_bytes(GAtServer *p)
        unsigned char *buf = ring_buffer_read_ptr(p->read_buf, p->read_so_far);
        enum ParserResult result;
 
-       while (p->channel && (p->read_so_far < len)) {
+       while (p->channel && p->is_online && (p->read_so_far < len)) {
                gsize rbytes = MIN(len - p->read_so_far, wrap - p->read_so_far);
                result = server_feed(p, (char *)buf, &rbytes);
 
@@ -764,6 +767,12 @@ static void new_bytes(GAtServer *p)
                                p->read_pos = 0;
                                p->last_result = G_AT_SERVER_RESULT_OK;
 
+                               /* Set offline mode so that server won't feed
+                                * the next command line until current line is
+                                * processed and final result code is flushed.
+                                */
+                               p->is_online = FALSE;
+
                                server_parse_line(p);
                        } else {
                                g_at_server_send_final(p,
@@ -1013,6 +1022,7 @@ GAtServer *g_at_server_new(GIOChannel *io)
        server->ref_count = 1;
        v250_settings_create(&server->v250);
        server->channel = io;
+       server->is_online = TRUE;
        server->command_list = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                        g_free,
                                                        at_notify_node_destroy);
-- 
1.6.6.1

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to