Download raw body.
move gotd_child_proc struct in gotd.c
I'm splitting the diff I sent yesterday into more manegeable bits.
This is not strictly needed, but sice the struct gotd_child_proc is
not used outside of gotd.c, let's move it there and allocate
dynamically listen_proc in gotd.
While here, I'm also dropping the `nhelpers' field which seems
currently unused.
diff /home/op/w/got
commit - a60eb2cc0fad47d21b6c6329245e25f548245c00
path + /home/op/w/got
blob - f15597dbd0e7299cbf018874f9d81d6c8dcaf403
file + gotd/gotd.c
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -73,6 +73,15 @@ struct gotd_client {
GOTD_CLIENT_STATE_ACCESS_GRANTED,
};
+struct gotd_child_proc {
+ pid_t pid;
+ enum gotd_procid type;
+ char repo_name[NAME_MAX];
+ char repo_path[PATH_MAX];
+ int pipe[2];
+ struct gotd_imsgev iev;
+};
+
struct gotd_client {
STAILQ_ENTRY(gotd_client) entry;
enum gotd_client_state state;
@@ -331,7 +340,7 @@ disconnect(struct gotd_client *client)
{
struct gotd_imsg_disconnect idisconnect;
struct gotd_child_proc *proc = client->repo;
- struct gotd_child_proc *listen_proc = &gotd.listen_proc;
+ struct gotd_child_proc *listen_proc = gotd.listen_proc;
uint64_t slot;
log_debug("uid %d: disconnecting", client->euid);
@@ -703,7 +712,7 @@ done:
client->euid, client->fd);
done:
if (err) {
- struct gotd_child_proc *listen_proc = &gotd.listen_proc;
+ struct gotd_child_proc *listen_proc = gotd.listen_proc;
struct gotd_imsg_disconnect idisconnect;
idisconnect.client_id = client->id;
@@ -753,7 +762,7 @@ gotd_shutdown(void)
disconnect(c);
}
- proc = &gotd.listen_proc;
+ proc = gotd.listen_proc;
msgbuf_clear(&proc->iev.ibuf.w);
close(proc->iev.ibuf.fd);
kill_proc(proc, 0);
@@ -960,7 +969,7 @@ gotd_dispatch_listener(int fd, short event, void *arg)
{
struct gotd_imsgev *iev = arg;
struct imsgbuf *ibuf = &iev->ibuf;
- struct gotd_child_proc *proc = &gotd.listen_proc;
+ struct gotd_child_proc *proc = gotd.listen_proc;
ssize_t n;
int shut = 0;
struct imsg imsg;
@@ -1488,8 +1497,12 @@ start_listener(char *argv0, const char *confpath, int
static void
start_listener(char *argv0, const char *confpath, int daemonize, int verbosity)
{
- struct gotd_child_proc *proc = &gotd.listen_proc;
+ struct gotd_child_proc *proc;
+ proc = calloc(1, sizeof(*proc));
+ if (proc == NULL)
+ fatal("calloc");
+
proc->type = PROC_LISTEN;
if (socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK,
@@ -1502,6 +1515,8 @@ start_listener(char *argv0, const char *confpath, int
proc->iev.handler = gotd_dispatch_listener;
proc->iev.events = EV_READ;
proc->iev.handler_arg = NULL;
+
+ gotd.listen_proc = proc;
}
static const struct got_error *
@@ -1948,7 +1963,7 @@ main(int argc, char **argv)
signal_add(&evsighup, NULL);
signal_add(&evsigusr1, NULL);
- gotd_imsg_event_add(&gotd.listen_proc.iev);
+ gotd_imsg_event_add(&gotd.listen_proc->iev);
event_dispatch();
blob - 35d6e95f4881eb3c4ce60156fce684fa03070cb4
file + gotd/gotd.h
--- gotd/gotd.h
+++ gotd/gotd.h
@@ -51,16 +51,6 @@ struct gotd_child_proc {
short events;
};
-struct gotd_child_proc {
- pid_t pid;
- enum gotd_procid type;
- char repo_name[NAME_MAX];
- char repo_path[PATH_MAX];
- int pipe[2];
- struct gotd_imsgev iev;
- size_t nhelpers;
-};
-
enum gotd_access {
GOTD_ACCESS_PERMITTED = 1,
GOTD_ACCESS_DENIED
@@ -120,13 +110,15 @@ struct gotd {
int max_connections;
};
+struct gotd_child_proc;
+
struct gotd {
pid_t pid;
char unix_socket_path[PATH_MAX];
char user_name[32];
struct gotd_repolist repos;
int nrepos;
- struct gotd_child_proc listen_proc;
+ struct gotd_child_proc *listen_proc;
struct timeval request_timeout;
struct timeval auth_timeout;
struct gotd_uid_connection_limit *connection_limits;
move gotd_child_proc struct in gotd.c