aboutsummaryrefslogtreecommitdiff
path: root/client/libacron
diff options
context:
space:
mode:
Diffstat (limited to 'client/libacron')
-rw-r--r--client/libacron/README.md3
-rw-r--r--client/libacron/net.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/client/libacron/README.md b/client/libacron/README.md
index 736b44a..bc7e879 100644
--- a/client/libacron/README.md
+++ b/client/libacron/README.md
@@ -215,9 +215,10 @@ size_t read;
while (1) {
if ((r = ac_receive(connection, buffer, pos, len, &obj, &read))) {
/* Handle error. */
+ /* read is undefined. */
break;
}
- pos += read;
+ pos += read; /* read is the bytes read in the last call. */
/* The obj is now referencing to a library allocated event or response. */
/* Do things with the event or response. */
ac_obj_free(obj);
diff --git a/client/libacron/net.c b/client/libacron/net.c
index cbbe113..62ee4a6 100644
--- a/client/libacron/net.c
+++ b/client/libacron/net.c
@@ -229,7 +229,9 @@ int ac_receive(void *connection,
/* In case the deserializer does not run at all. */
memset(res, 0, sizeof(struct ac_result));
if (len) {
+ size_t pos_starting = pos;
for (; pos < len; pos += retval) {
+ LOGDV("wic_parse[%lu]", pos);
retval = wic_parse(inst, &ptr[pos], len - pos);
if (wic_get_state(inst) == WIC_STATE_CLOSED) {
LOGE("Connection closed.");
@@ -242,7 +244,7 @@ int ac_receive(void *connection,
break;
}
}
- *len_read = pos;
+ *len_read = pos - pos_starting;
} else {
retval = wic_parse(inst, &ptr[pos], len - pos);
if (wic_get_state(inst) == WIC_STATE_CLOSED) {