X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=stream.cpp;h=4e5ca24cceab8870dfdfa00e66b161aecc61f729;hp=3ee1a434d2e6fe6c3cc73fcc84d89d860efd0f05;hb=HEAD;hpb=7ec54788f88dde7b083ba6cfd30732b32295b54a diff --git a/stream.cpp b/stream.cpp index 3ee1a43..c79391a 100644 --- a/stream.cpp +++ b/stream.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -67,6 +68,9 @@ Stream::Stream(const StreamProto &serialized, int data_fd) exit(1); } + // Set the close-on-exec parameter back on the backlog fd. + fcntl(data_fd, F_SETFD, FD_CLOEXEC); + for (ssize_t point : serialized.suitable_starting_point()) { if (point == -1) { // Can happen when upgrading from before 1.1.3, @@ -103,6 +107,10 @@ StreamProto Stream::serialize() serialized.set_first_fragment_index(first_fragment_index); serialized.set_discontinuity_counter(discontinuity_counter); + // Unset the close-on-exec flag for the backlog fd. + // (This can't leak into a child, since there's only one thread left.) + fcntl(data_fd, F_SETFD, 0); + serialized.set_url(url); data_fd = -1; return serialized;