Skip to content

Commit

Permalink
Possible fix for esnet#1809 - replace rcv()/read()/write() with Nread…
Browse files Browse the repository at this point in the history
…()/Nwrite()
  • Loading branch information
davidBar-On committed Dec 14, 2024
1 parent 2a29844 commit 1eaa60c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/iperf_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ iperf_handle_message_client(struct iperf_test *test)
iperf_printf(test, "Reading new State from the Server - current state is %d-%s\n", test->state, state_to_text(test->state));
}

/*!!! Why is this read() and not Nread()? */
if ((rval = read(test->ctrl_sck, (char*) &test->state, sizeof(signed char))) <= 0) {
if ((rval = Nread(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp)) <= 0) {
if (rval == 0) {
i_errno = IECTRLCLOSE;
return -1;
Expand Down
6 changes: 3 additions & 3 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ iperf_udp_accept(struct iperf_test *test)

/* Let the client know we're ready "accept" another UDP "stream" */
buf = UDP_CONNECT_REPLY;
if (write(s, &buf, sizeof(buf)) < 0) {
if (Nwrite(s, (char *)&buf, sizeof(buf), Pudp) < 0) {
i_errno = IESTREAMWRITE;
return -1;
}
Expand Down Expand Up @@ -578,7 +578,7 @@ iperf_udp_connect(struct iperf_test *test)
if (test->debug) {
printf("Sending Connect message to Socket %d\n", s);
}
if (write(s, &buf, sizeof(buf)) < 0) {
if (Nwrite(s, (char *)&buf, sizeof(buf), Pudp) < 0) {
// XXX: Should this be changed to IESTREAMCONNECT?
i_errno = IESTREAMWRITE;
return -1;
Expand All @@ -592,7 +592,7 @@ iperf_udp_connect(struct iperf_test *test)
if (test->reverse) /* In reverse mode allow few packets to have the "accept" response - to handle out of order packets */
max_len_wait_for_reply += MAX_REVERSE_OUT_OF_ORDER_PACKETS * test->settings->blksize;
do {
if ((sz = recv(s, &buf, sizeof(buf), 0)) < 0) {
if ((sz = Nread(s, (char *)&buf, sizeof(buf), Pudp)) < 0) {
i_errno = IESTREAMREAD;
return -1;
}
Expand Down

0 comments on commit 1eaa60c

Please sign in to comment.