The ctrl_sck does not need to be in the select write_set, and indeed
having it there may cause the select to return immediately every time. Which is bad, m'kay? Also, changed the coding idiom used to keep track of the maximum fd in the fd sets, to be clearer.
Этот коммит содержится в:
родитель
e35f2035d5
Коммит
082cbb0ee6
@ -40,7 +40,7 @@ iperf_create_streams(struct iperf_test *test)
|
||||
|
||||
FD_SET(s, &test->read_set);
|
||||
FD_SET(s, &test->write_set);
|
||||
test->max_fd = (test->max_fd < s) ? s : test->max_fd;
|
||||
if (s > test->max_fd) test->max_fd = s;
|
||||
|
||||
sp = iperf_new_stream(test, s);
|
||||
if (!sp)
|
||||
@ -268,8 +268,7 @@ iperf_connect(struct iperf_test *test)
|
||||
}
|
||||
|
||||
FD_SET(test->ctrl_sck, &test->read_set);
|
||||
FD_SET(test->ctrl_sck, &test->write_set);
|
||||
test->max_fd = (test->ctrl_sck > test->max_fd) ? test->ctrl_sck : test->max_fd;
|
||||
if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ iperf_server_listen(struct iperf_test *test)
|
||||
FD_ZERO(&test->read_set);
|
||||
FD_ZERO(&test->write_set);
|
||||
FD_SET(test->listener, &test->read_set);
|
||||
test->max_fd = (test->listener > test->max_fd) ? test->listener : test->max_fd;
|
||||
if (test->listener > test->max_fd) test->max_fd = test->listener;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -123,15 +123,13 @@ iperf_accept(struct iperf_test *test)
|
||||
|
||||
if (test->ctrl_sck == -1) {
|
||||
/* Server free, accept new client */
|
||||
if (Nread(s, test->cookie, COOKIE_SIZE, Ptcp) < 0) {
|
||||
test->ctrl_sck = s;
|
||||
if (Nread(test->ctrl_sck, test->cookie, COOKIE_SIZE, Ptcp) < 0) {
|
||||
i_errno = IERECVCOOKIE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
FD_SET(s, &test->read_set);
|
||||
FD_SET(s, &test->write_set);
|
||||
test->max_fd = (s > test->max_fd) ? s : test->max_fd;
|
||||
test->ctrl_sck = s;
|
||||
FD_SET(test->ctrl_sck, &test->read_set);
|
||||
if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck;
|
||||
|
||||
if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0)
|
||||
return -1;
|
||||
@ -498,7 +496,7 @@ iperf_run_server(struct iperf_test *test)
|
||||
|
||||
FD_SET(s, &test->read_set);
|
||||
FD_SET(s, &test->write_set);
|
||||
test->max_fd = (s > test->max_fd) ? s : test->max_fd;
|
||||
if (s > test->max_fd) test->max_fd = s;
|
||||
|
||||
streams_accepted++;
|
||||
if (test->on_new_stream)
|
||||
@ -521,8 +519,8 @@ iperf_run_server(struct iperf_test *test)
|
||||
return -1;
|
||||
}
|
||||
test->listener = s;
|
||||
test->max_fd = (s > test->max_fd ? s : test->max_fd);
|
||||
FD_SET(test->listener, &test->read_set);
|
||||
if (test->listener > test->max_fd) test->max_fd = test->listener;
|
||||
}
|
||||
}
|
||||
test->prot_listener = -1;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user