Skip to content

Commit

Permalink
Additional debug messages as Nread() returned 0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Dec 13, 2024
1 parent ca86400 commit 0ad08a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,7 @@ JSON_read(int fd, int max_size)
char *str;
cJSON *json = NULL;
int rc;
char msg_buf[256];

/*
* Read a four-byte integer, which is the length of the JSON to follow.
Expand Down Expand Up @@ -2788,8 +2789,8 @@ JSON_read(int fd, int max_size)
json = cJSON_Parse(str);
}
else {
printf("*** TEMP DEBUG - Parameters JSON: expected %d bytes but received %d bytes;\n", hsize, rc); // [DBO] ???
warning("JSON size of data read does not correspond to offered length");
sprintf(msg_buf, "JSON size of data read does not correspond to offered length - expected %d bytes but received %d bytes; errno=%d", hsize, rc, errno);
warning(msg_buf);
}
}
free(str);
Expand Down
3 changes: 3 additions & 0 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,14 @@ Nread(int fd, char *buf, size_t count, int prot)
return NET_HARDERROR;
}
if (r == 0) {
printf("*** TEMP DEBUG: Nread() select() 1 returned 0 (timeout), errno=%d;\n", errno); // [DBO] ???
return 0;
}
}

while (nleft > 0) {
r = read(fd, buf, nleft);
printf("*** TEMP DEBUG: Nread() read() returned %ld, errno=%d;\n", r, errno); // [DBO] ???
if (r < 0) {
/* XXX EWOULDBLOCK can't happen without non-blocking sockets */
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
Expand Down Expand Up @@ -445,6 +447,7 @@ Nread(int fd, char *buf, size_t count, int prot)
return NET_HARDERROR;
}
if (r == 0) {
printf("*** TEMP DEBUG: Nread() select() 2 returned 0 (timeout), errno=%d;\n", errno); // [DBO] ???
break;
}
}
Expand Down

0 comments on commit 0ad08a0

Please sign in to comment.