#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
Stream::Stream(const StreamProto &serialized, int data_fd)
: url(serialized.url()),
+ unavailable(serialized.unavailable()),
http_header(serialized.http_header()),
stream_header(serialized.stream_header()),
encoding(Stream::STREAM_ENCODING_RAW), // Will be changed later.
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,
StreamProto Stream::serialize()
{
StreamProto serialized;
+ serialized.set_unavailable(unavailable);
serialized.set_http_header(http_header);
serialized.set_stream_header(stream_header);
serialized.add_data_fds(data_fd);
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;
void Stream::set_header(const std::string &new_http_header, const std::string &new_stream_header)
{
+ unavailable = false;
http_header = new_http_header;
if (new_stream_header == stream_header) {
return;