timer_del(&c->timer);
close(c->socket.fd);
json_delete(c->json);
- xfree(c);
+ mp_delete(c->pool); // This includes the connection structure
num_connections--;
}
if (fcntl(new_sk, F_SETFL, fcntl(new_sk, F_GETFL) | O_NONBLOCK) < 0)
die("Cannot set O_NONBLOCK: %m");
- struct client *c = xmalloc_zero(sizeof(*c));
+ struct mempool *mp = mp_new(4096);
+ struct client *c = mp_alloc_zero(mp, sizeof(*c));
+ c->pool = mp;
c->json = json_new();
c->socket.fd = new_sk;
if (listen(sk, 64) < 0)
die("listen(): %m");
- int one;
+ int one = 1;
if (setsockopt(sk, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0)
die("setsockopt(SO_PASSCRED): %m");
listen_socket.read_handler = listen_read_handler;
file_add(&listen_socket);
+ if (chmod(socket_path, 0666) < 0)
+ die("Cannot chmod socket: %m");
+
msg(L_INFO, "Listening on %s", socket_path);
}