commit - 0835bf10ee863d91a617270780cd79c405c6a992
commit + 789434649a5946c62ea73cf86e25f2c14a2c25f5
blob - 4a31b013e208dc44217e5adb1298f296a23afd3e
blob + 22ba4bf3e47e8a047ecc9a93f07f9a543a54fb7d
--- gotd/gotd.c
+++ gotd/gotd.c
enum gotd_client_state {
GOTD_CLIENT_STATE_NEW,
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 {
{
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);
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;
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);
wait_for_child(proc->pid);
+ free(proc)
log_info("terminating");
exit(0);
{
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;
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,
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 *
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
blob + e902d6f53b03f7682202e2b9b3d0af5fc28c25b6
--- gotd/gotd.h
+++ gotd/gotd.h
void *handler_arg;
struct event ev;
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 {
uid_t uid;
int max_connections;
};
+
+struct gotd_child_proc;
struct gotd {
pid_t pid;
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;