From 19b9e4e9b1aab03865b500fe4277869f98300464 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 13 Jun 2021 19:16:29 -0400 Subject: Added the `repos` parameter to both `main_loop()`, and `cleanup()`, and also call the git initialization code in the main program. --- pullreqd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'pullreqd.c') diff --git a/pullreqd.c b/pullreqd.c index 15d05f3..ccd1fb3 100644 --- a/pullreqd.c +++ b/pullreqd.c @@ -162,7 +162,7 @@ int init_socket(config *cfg) { return fd; } -int main_loop(config *cfg, int listen_socket) { +int main_loop(config *cfg, int listen_socket, git_repository **repos) { int done = 0; for (; !done;) { @@ -172,7 +172,7 @@ int main_loop(config *cfg, int listen_socket) { return 0; } -void cleanup(config *cfg, int listen_socket) { +void cleanup(config *cfg, int listen_socket, git_repository **repos) { if (listen_socket > 0) { close(listen_socket); /* Is this a unix domain socket? */ @@ -184,10 +184,15 @@ void cleanup(config *cfg, int listen_socket) { if (cfg) { cleanup_config(cfg); } + + if (repos) { + cleanup_git(repos); + } } int main(int argc, char **argv) { config *cfg; + git_repository **repos; char *config_file = "test.conf"; int config_read = 0; int listen_socket = -1; @@ -207,10 +212,13 @@ int main(int argc, char **argv) { /* Did we successfully read the config file, and create the listen socket? */ if (config_read && listen_socket >= 0) { - exit_status = main_loop(cfg, listen_socket); + repos = init_git(cfg); + if (repos != NULL) { + exit_status = main_loop(cfg, listen_socket, repos); + } } - cleanup(cfg, listen_socket); + cleanup(cfg, listen_socket, repos); log(LOG_NOTICE, "pullreqd stopped."); -- cgit v1.2.3-13-gbd6f