summaryrefslogtreecommitdiffstats
path: root/gatchat/gatchat.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-01-15 10:24:01 -0600
committerDenis Kenzior <denkenz@gmail.com>2010-01-15 10:24:01 -0600
commite8d18946b9de07c684ed06494f16900f887c5cd4 (patch)
tree10699c55351a1df60978ff3c4c0ccf94ff23c757 /gatchat/gatchat.c
parentaec5b8a44fa2fbece87441656eaf7ffb9a53fc6e (diff)
downloadofono-e8d18946b9de07c684ed06494f16900f887c5cd4.tar.bz2
Fix: One more fix for disconnect detection
In situations where lots of data is generated by the remote side (e.g. phonebook is being read) we can get our ring buffer filled up. In this case setting rbytes to zero first and then breaking out of the loop leads to an erroneous disconnect detection. The fix is to move setting of rbytes after we know we still have some space.
Diffstat (limited to 'gatchat/gatchat.c')
-rw-r--r--gatchat/gatchat.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 8af927ed..7dfc4cb8 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -776,13 +776,12 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
/* Regardless of condition, try to read all the data available */
do {
- rbytes = 0;
-
toread = ring_buffer_avail_no_wrap(chat->buf);
if (toread == 0)
break;
+ rbytes = 0;
buf = ring_buffer_write_ptr(chat->buf);
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);