- if (is_reexec) {
- // Put back the existing clients. It doesn't matter which server we
- // allocate them to, so just do round-robin. However, we need to add
- // them after the mark pools have been set up.
- for (int i = 0; i < loaded_state.clients_size(); ++i) {
- servers->add_client_from_serialized(loaded_state.clients(i));
+ short_response_pool.clear(); // No longer needed; the clients have their own refcounts now.
+
+ // Put back the HLS zombies. There's no really good allocation here
+ // except round-robin; it would be marginally more efficient to match it
+ // to the client (since that would have them deleted immediately when
+ // the client requests the next fragment, instead of being later weeded
+ // out during statistics collection), but it's not a big deal.
+ for (const HLSZombieProto &zombie_proto : loaded_state.hls_zombies()) {
+ servers->add_hls_zombie_from_serialized(zombie_proto);
+ }
+
+ servers->run();
+
+ // Now delete all inputs that are longer in use, and start the others.
+ for (auto input_it = inputs.begin(); input_it != inputs.end(); ) {
+ if (input_it->second.refcount == 0) {
+ if (input_it->first.second == Input::INPUT_ENCODING_RAW) {
+ log(WARNING, "Raw input '%s' no longer in use, closing.",
+ input_it->first.first.c_str());
+ } else {
+ assert(input_it->first.second == Input::INPUT_ENCODING_METACUBE);
+ log(WARNING, "Metacube input '%s' no longer in use, closing.",
+ input_it->first.first.c_str());
+ }
+ input_it->second.input->close_socket();
+ delete input_it->second.input;
+ inputs.erase(input_it++);
+ } else {
+ input_it->second.input->run();
+ ++input_it;