diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-01-15 10:24:01 -0600 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-15 12:10:59 -0800 |
commit | 5fbfa700fb4b3ccdafd16343d02462f7ba408cee (patch) | |
tree | a115e8662dfac7f4ea0c83b2ee16648b2a945102 /gatchat | |
parent | 5d48d4c3b5ed078d42b82b2be066265cc39ef401 (diff) | |
download | connman-5fbfa700fb4b3ccdafd16343d02462f7ba408cee.tar.gz connman-5fbfa700fb4b3ccdafd16343d02462f7ba408cee.tar.bz2 connman-5fbfa700fb4b3ccdafd16343d02462f7ba408cee.zip |
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')
-rw-r--r-- | gatchat/gatchat.c | 3 |
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); |