X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=udpinput.cpp;h=4b421a3e4fe90c91732a7a24c53adc476175fd7d;hb=refs%2Fheads%2Fmaster;hp=0035640ad4a91bd6ed2d4d59f3a6db8feb677a6d;hpb=50651c954803c1941e6ad1bb494712891c18f7d2;p=cubemap diff --git a/udpinput.cpp b/udpinput.cpp index 0035640..824c3bc 100644 --- a/udpinput.cpp +++ b/udpinput.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -120,6 +121,10 @@ UDPInput::UDPInput(const InputProto &serialized) : url(serialized.url()), sock(serialized.sock()) { + // Set back the close-on-exec flag for the socket. + // (This can't leak into a child, since we haven't been started yet.) + fcntl(sock, F_SETFD, FD_CLOEXEC); + // Should be verified by the caller. string protocol; bool ok = parse_url(url, &protocol, &user, &host, &port, &path); @@ -139,6 +144,10 @@ UDPInput::UDPInput(const InputProto &serialized) InputProto UDPInput::serialize() const { + // Unset the close-on-exec flag for the socket. + // (This can't leak into a child, since there's only one thread left.) + fcntl(sock, F_SETFD, 0); + InputProto serialized; serialized.set_url(url); serialized.set_sock(sock); @@ -210,7 +219,7 @@ void UDPInput::do_work() ret = recv(sock, packet_buf, sizeof(packet_buf), 0); } while (ret == -1 && errno == EINTR); - if (ret <= 0) { + if (ret < 0) { // Note that zero-byte packets are legal. log_perror("recv"); close_socket(); continue; @@ -223,7 +232,7 @@ void UDPInput::do_work() } for (size_t stream_index : stream_indices) { - servers->add_data(stream_index, packet_buf, ret, /*metacube_flags=*/0); + servers->add_data(stream_index, packet_buf, ret, /*metacube_flags=*/0, /*pts=*/RationalPTS()); } } }