+ int data_fd;
+ if (i < int(data_fds.size())) {
+ // Reuse one of the existing file descriptors.
+ data_fd = data_fds[i];
+ } else {
+ // Clone the first one.
+ if (contents.empty()) {
+ if (!read_tempfile(data_fds[0], &contents)) {
+ exit(1);
+ }
+ }
+ data_fd = make_tempfile(contents);
+ }
+
+ servers[i].add_stream_from_serialized(stream, data_fd);
+ }
+
+ // Close and delete any leftovers, if the number of servers was reduced.
+ for (size_t i = num_servers; i < data_fds.size(); ++i) {
+ int ret;
+ do {
+ ret = close(data_fds[i]); // Implicitly deletes the file.
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret == -1) {
+ log_perror("close");
+ // Can still continue.
+ }