X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=stream.cpp;h=5ea2cd03601491f8fe64070fd4b33b71f33dd4d8;hp=109d2fd4a90116398e8b638816872cabf06b22ce;hb=7c26826d3c485f4f18a6c427f520dc470e68f94a;hpb=534764f026b82b144e974882c8e53c4cd8d21b68 diff --git a/stream.cpp b/stream.cpp index 109d2fd..5ea2cd0 100644 --- a/stream.cpp +++ b/stream.cpp @@ -1,14 +1,15 @@ -#include +#include #include -#include +#include #include +#include #include #include #include -#include "state.pb.h" #include "log.h" #include "metacube.h" +#include "state.pb.h" #include "stream.h" #include "util.h" @@ -30,13 +31,7 @@ Stream::Stream(const string &stream_id, size_t backlog_size, Encoding encoding) Stream::~Stream() { if (data_fd != -1) { - int ret; - do { - ret = close(data_fd); - } while (ret == -1 && errno == EINTR); - if (ret == -1) { - log_perror("close"); - } + safe_close(data_fd); } } @@ -109,11 +104,14 @@ void Stream::set_backlog_size(size_t new_size) // Create a new, empty data file. data_fd = make_tempfile(""); + if (data_fd == -1) { + exit(1); + } backlog_size = new_size; // Now cheat a bit by rewinding, and adding all the old data back. bytes_received -= existing_data.size(); - add_data(existing_data.data(), existing_data.size()); + add_data_raw(existing_data.data(), existing_data.size()); } void Stream::put_client_to_sleep(Client *client)