Skip to content

Commit

Permalink
Fix issue 1129 for not sending stat to to undefined socket (esnet#1132)
Browse files Browse the repository at this point in the history
This fix avoids trying to do operations on a socket that was never opened successfully.
  • Loading branch information
davidBar-On authored and hanvari committed Jul 3, 2021
1 parent 4e2b847 commit 931dfab
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1628,10 +1628,12 @@ int iperf_open_logfile(struct iperf_test *test)
int
iperf_set_send_state(struct iperf_test *test, signed char state)
{
test->state = state;
if (Nwrite(test->ctrl_sck, (char*) &state, sizeof(state), Ptcp) < 0) {
i_errno = IESENDMESSAGE;
return -1;
if (test->ctrl_sck >= 0) {
test->state = state;
if (Nwrite(test->ctrl_sck, (char*) &state, sizeof(state), Ptcp) < 0) {
i_errno = IESENDMESSAGE;
return -1;
}
}
return 0;
}
Expand Down

0 comments on commit 931dfab

Please sign in to comment.