diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/const.h | 3 | ||||
-rw-r--r-- | src/server.c | 11 | ||||
-rw-r--r-- | src/worker.c | 9 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/const.h b/src/const.h index 8ac2e33..08f20e5 100644 --- a/src/const.h +++ b/src/const.h @@ -6,4 +6,7 @@ #endif #define DEFAULT_PORT "5556" +#define CMD_CI_RUN "ci-run" +#define CMD_WORKER_NEW "worker-new" + #endif diff --git a/src/server.c b/src/server.c index e56ccd0..8c2dbe6 100644 --- a/src/server.c +++ b/src/server.c @@ -1,6 +1,7 @@ #include "server.h" #include "ci_queue.h" #include "compiler.h" +#include "const.h" #include "log.h" #include "msg.h" #include "signal.h" @@ -67,7 +68,7 @@ static int worker_ci_run(int fd, const struct ci_queue_entry *ci_run) struct msg request, response; int ret = 0; - char *argv[] = {"ci_run", ci_run->url, ci_run->rev, NULL}; + char *argv[] = {CMD_CI_RUN, ci_run->url, ci_run->rev, NULL}; ret = msg_from_argv(&request, argv); if (ret < 0) @@ -186,13 +187,13 @@ static int worker_thread(struct server *server, int fd) return ret; } -static int msg_new_worker_handler(struct server *server, int client_fd, +static int msg_worker_new_handler(struct server *server, int client_fd, UNUSED const struct msg *request) { return worker_thread(server, client_fd); } -static int msg_new_worker_parser(UNUSED const struct msg *msg) +static int msg_worker_new_parser(UNUSED const struct msg *msg) { return 1; } @@ -267,8 +268,8 @@ struct msg_descr { }; struct msg_descr messages[] = { - {"new_worker", msg_new_worker_parser, msg_new_worker_handler}, - {"ci_run", msg_ci_run_parser, msg_ci_run_handler}, + {CMD_WORKER_NEW, msg_worker_new_parser, msg_worker_new_handler}, + {CMD_CI_RUN, msg_ci_run_parser, msg_ci_run_handler}, }; static int server_msg_handler(struct server *server, int client_fd, const struct msg *request) diff --git a/src/worker.c b/src/worker.c index fef6b78..f107d7e 100644 --- a/src/worker.c +++ b/src/worker.c @@ -1,5 +1,6 @@ #include "worker.h" #include "ci.h" +#include "const.h" #include "git.h" #include "log.h" #include "msg.h" @@ -42,9 +43,9 @@ void worker_destroy(struct worker *worker) libgit_shutdown(); } -static int msg_send_new_worker(const struct worker *worker) +static int msg_send_worker_new(const struct worker *worker) { - static char *argv[] = {"new_worker", NULL}; + static char *argv[] = {CMD_WORKER_NEW, NULL}; struct msg msg; int ret = 0; @@ -124,7 +125,7 @@ struct msg_descr { }; struct msg_descr messages[] = { - {"ci_run", msg_ci_run_parser, msg_ci_run_handler}, + {CMD_CI_RUN, msg_ci_run_parser, msg_ci_run_handler}, }; static int worker_msg_handler(struct worker *worker, const struct msg *request) @@ -154,7 +155,7 @@ int worker_main(struct worker *worker, UNUSED int argc, UNUSED char *argv[]) { int ret = 0; - ret = msg_send_new_worker(worker); + ret = msg_send_worker_new(worker); if (ret < 0) return ret; |