aboutsummaryrefslogtreecommitdiff
path: root/client/helloworld/main.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/helloworld/main.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/helloworld/main.c')
-rw-r--r--client/helloworld/main.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/client/helloworld/main.c b/client/helloworld/main.c
index 079b957..d744851 100644
--- a/client/helloworld/main.c
+++ b/client/helloworld/main.c
@@ -349,12 +349,15 @@ int main(int argc, char **argv) {
}
}
if ((r = lock())) { goto end; }
- if ((r = ac_receive(connection, buffer, pos, bytes, &obj, &read))) {
- bool again = r == AC_E_AGAIN;
- if (!again) {
- unlock();
- goto end;
+ while (pos < bytes) {
+ if ((r = ac_receive(connection, buffer, pos, bytes, &obj, &read))) {
+ bool again = r == AC_E_AGAIN;
+ if (!again) {
+ unlock();
+ goto end;
+ }
}
+ pos += read;
}
r = process(connection, obj);
if ((r = unlock())) { goto end; }