#include <stdio.h>
#include <arpa/inet.h>
+#include <fcntl.h>
#include <netinet/in.h>
#include <stdint.h>
#include <sys/socket.h>
+#include <unistd.h>
#include "client.h"
#include "log.h"
bytes_lost(serialized.bytes_lost()),
num_loss_events(serialized.num_loss_events())
{
+ // Set back the close-on-exec flag for the socket.
+ // (This can't leak into a child, since we haven't been started yet.)
+ fcntl(sock, F_SETFD, FD_CLOEXEC);
+
if (stream != nullptr) {
if (setsockopt(sock, SOL_SOCKET, SO_MAX_PACING_RATE, &stream->pacing_rate, sizeof(stream->pacing_rate)) == -1) {
if (stream->pacing_rate != ~0U) {
ClientProto Client::serialize(unordered_map<const string *, size_t> *short_response_pool) const
{
+ // Unset the close-on-exec flag for the socket.
+ // (This can't leak into a child, since there's only one thread left.)
+ fcntl(sock, F_SETFD, 0);
+
ClientProto serialized;
serialized.set_sock(sock);
serialized.set_remote_addr(remote_addr);