]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Stop leaking the state fd on reload.
[cubemap] / main.cpp
index 194ffc7fa97c77fcdc13d9872a234141bb762cb3..28acd3962d6a5950e5a92487aed675c4ff2f2c4e 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -338,7 +338,7 @@ int main(int argc, char **argv)
        char argv0_canon[PATH_MAX];
        char config_filename_canon[PATH_MAX];
 
-       if (realpath(argv[0], argv0_canon) == NULL) {
+       if (realpath("/proc/self/exe", argv0_canon) == NULL) {
                log_perror(argv[0]);
                exit(1);
        }
@@ -393,7 +393,7 @@ start:
        if (state_fd != -1) {
                log(INFO, "Deserializing state from previous process...");
                string serialized;
-               if (!read_tempfile(state_fd, &serialized)) {
+               if (!read_tempfile_and_close(state_fd, &serialized)) {
                        exit(1);
                }
                if (!loaded_state.ParseFromString(serialized)) {
@@ -420,12 +420,6 @@ start:
                                        data_fds.push_back(stream.data_fds(j));
                                }
 
-                               // Older versions stored the data once in the protobuf instead of
-                               // sending around file descriptors.
-                               if (data_fds.empty() && stream.has_data()) {
-                                       data_fds.push_back(make_tempfile(stream.data()));
-                               }
-
                                servers->add_stream_from_serialized(stream, data_fds);
                                deserialized_urls.insert(stream.url());
 
@@ -437,15 +431,6 @@ start:
                for (int i = 0; i < loaded_state.inputs_size(); ++i) {
                        InputProto serialized_input = loaded_state.inputs(i);
 
-                       // Older versions did not store the stream header in the input,
-                       // only in each stream. We need to have the stream header in the
-                       // input as well, in case we create a new stream reusing the same input.
-                       // Thus, we put it into place here if it's missing.
-                       if (!serialized_input.has_stream_header() &&
-                           stream_headers_for_url.count(serialized_input.url()) != 0) {
-                               serialized_input.set_stream_header(stream_headers_for_url[serialized_input.url()]);
-                       }
-
                        InputWithRefcount iwr;
                        iwr.input = create_input(serialized_input);
                        iwr.refcount = 0;