aboutsummaryrefslogtreecommitdiff
path: root/client/libacron/net.c
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-08-09 18:46:45 -0700
committerTrumeet <yuuta@yuuta.moe>2022-08-09 18:46:45 -0700
commit6f2cfc118701b59d96862199204aef7834f9db86 (patch)
treeafce2dc865458796912962cdab288699617de730 /client/libacron/net.c
parent7edaa14c2c822e5b776edaa6534753b258d29488 (diff)
downloadacron-6f2cfc118701b59d96862199204aef7834f9db86.tar
acron-6f2cfc118701b59d96862199204aef7834f9db86.tar.gz
acron-6f2cfc118701b59d96862199204aef7834f9db86.tar.bz2
acron-6f2cfc118701b59d96862199204aef7834f9db86.zip
fix(libacron/acronc/helloworld): ac_receive: 'read' should be the delta value of bytes read in the call, not the absolute position
Also clearify that 'read' is undefined if the function fails.
Diffstat (limited to 'client/libacron/net.c')
-rw-r--r--client/libacron/net.c4
1 files changed, 3 insertions, 1 deletions
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) {