gpointer user_disconnect_data; /* user disconnect data */
struct ring_buffer *buf; /* Current read buffer */
guint read_so_far; /* Number of bytes processed */
+ guint max_read_attempts; /* max number of read attempts */
GAtDebugFunc debugf; /* debugging output function */
gpointer debug_data; /* Data to pass to debug func */
char *pdu_notify; /* Unsolicited Resp w/ PDU */
gsize rbytes;
gsize toread;
gsize total_read = 0;
+ guint read_count = 0;
if (cond & G_IO_NVAL)
return FALSE;
do {
toread = ring_buffer_avail_no_wrap(chat->buf);
- if (toread == 0)
+ if (toread == 0) {
+ err = G_IO_ERROR_NONE;
break;
+ }
rbytes = 0;
buf = ring_buffer_write_ptr(chat->buf);
g_at_util_debug_chat(TRUE, (char *)buf, rbytes,
chat->debugf, chat->debug_data);
+ read_count++;
+
total_read += rbytes;
if (rbytes > 0)
ring_buffer_write_advance(chat->buf, rbytes);
- } while (err == G_IO_ERROR_NONE && rbytes > 0);
+ } while (err == G_IO_ERROR_NONE && rbytes > 0 &&
+ read_count < chat->max_read_attempts);
if (total_read > 0)
new_bytes(chat);
chat->next_notify_id = 1;
chat->debugf = NULL;
+ chat->max_read_attempts = 1;
+
chat->buf = ring_buffer_new(4096);
if (!chat->buf)