summaryrefslogtreecommitdiff
path: root/gatchat
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-08-06 14:23:04 -0500
committerMarcel Holtmann <marcel@holtmann.org>2009-08-06 17:49:11 -0700
commita2a370c17591bef196be6dd4a9f6ee43ff5ac59d (patch)
tree947d761641ef54c6bf654918c69f565b57d3220a /gatchat
parent82ccfae22a5d1638870d283ecf953d9b2a8a184f (diff)
downloadconnman-a2a370c17591bef196be6dd4a9f6ee43ff5ac59d.tar.gz
connman-a2a370c17591bef196be6dd4a9f6ee43ff5ac59d.tar.bz2
connman-a2a370c17591bef196be6dd4a9f6ee43ff5ac59d.zip
Make overflow code a bit better
Diffstat (limited to 'gatchat')
-rw-r--r--gatchat/gatchat.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 8263ad71..6cb52074 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -584,6 +584,10 @@ static void new_bytes(GAtChat *p)
wrap -= p->read_so_far;
p->read_so_far = 0;
}
+
+ /* We're overflowing the buffer, shutdown the socket */
+ if (ring_buffer_avail(p->buf) == 0)
+ g_at_chat_shutdown(p);
}
static gboolean received_data(GIOChannel *channel, GIOCondition cond,
@@ -605,12 +609,8 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
toread = ring_buffer_avail_no_wrap(chat->buf);
- /* We're going to start overflowing the buffer
- * this cannot happen under normal circumstances, so probably
- * the channel is getting garbage, drop off
- */
if (toread == 0)
- return FALSE;
+ break;
buf = ring_buffer_write_ptr(chat->buf);
@@ -629,9 +629,6 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
if (cond & (G_IO_HUP | G_IO_ERR))
return FALSE;
- if (err == G_IO_ERROR_NONE && rbytes == 0)
- return FALSE;
-
if (err != G_IO_ERROR_NONE && err != G_IO_ERROR_AGAIN)
return FALSE;