Make UDP packet reception work right with non-blocking sockets and enable.
We need this to permit a UDP receiving iperf3 server to listen on its control channel. The fix for non-blocking sockets basically makes sure that if we do a read on a non-blocking sockets, but there's no data, the UDP processing code does *not* try to do the normal protocol packet processing on the non-existent packet. This is part of an ongoing fix for issue #212 but also should have been a part of the fix for issue #125.
Этот коммит содержится в:
родитель
78033c4359
Коммит
8694d1db0d
@ -534,8 +534,14 @@ iperf_run_server(struct iperf_test *test)
|
||||
FD_SET(s, &test->read_set);
|
||||
if (s > test->max_fd) test->max_fd = s;
|
||||
|
||||
// If the protocol isn't UDP, set nonblocking sockets
|
||||
if (test->protocol->id != Pudp) {
|
||||
/*
|
||||
* If the protocol isn't UDP, or even if it is but
|
||||
* we're the receiver, set nonblocking sockets.
|
||||
* We need this to allow a server receiver to
|
||||
* maintain interactivity with the control channel.
|
||||
*/
|
||||
if (test->protocol->id != Pudp ||
|
||||
!test->sender) {
|
||||
setnonblocking(s, 1);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,12 @@ iperf_udp_recv(struct iperf_stream *sp)
|
||||
|
||||
r = Nread(sp->socket, sp->buffer, size, Pudp);
|
||||
|
||||
if (r < 0)
|
||||
/*
|
||||
* If we got an error in the read, or if we didn't read anything
|
||||
* because the underlying read(2) got a EAGAIN, then skip packet
|
||||
* processing.
|
||||
*/
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
sp->result->bytes_received += r;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user