Fix issue 1129 for not sending stat to to undefined socket (#1132)

This fix avoids trying to do operations on a socket that was never opened successfully.
This commit is contained in:
David Bar-On 2021-04-09 22:33:06 +03:00 committed by GitHub
parent 53a68308ba
commit 44c6fed2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}