Skip to content

Commit 4873680

Browse files
authored
set internal socket to blocking (#78)
reads (especially on large messages) could error due to not all message available on socket at time of read. wasnt checks for incomplete read/write
1 parent 311ee91 commit 4873680

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/mqtt.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ K mqttCallback(int fd){
475475
break;
476476
case MSG_TYPE_RCVD:{
477477
const long expected = cb_data.body.size;
478-
// Don't use MSG_WAITALL since async sd1(-fd, ...) was used. So call recv until we have
479-
// the expected number of bytes otherwise the message sequencing can get out of step.
480478
long actual;
481479
char* body = malloc(expected);
482480
for (rc = 0, actual = 0;
@@ -521,8 +519,7 @@ EXP K init(K UNUSED(X)){
521519
fprintf(stderr,"Init failed. socketpair: %s\n", getSysError(buff,sizeof(buff)));
522520
return 0;
523521
}
524-
// Have to use (0 - fd) rather than simple negate, since SOCKET on Windows is unsigned ptr.
525-
pr0(sd1(0 - spair[0], &mqttCallback));
522+
pr0(sd1(spair[0], &mqttCallback));
526523
validinit = 1;
527524
atexit(detach);
528525
return 0;

0 commit comments

Comments
 (0)