aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-28 23:03:46 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-28 23:03:46 +0200
commit6295901a73828fcb9a2dd94e8bd5d59f1a5f4a91 (patch)
treea314349de29a9b0231d33157e927883b14e1d644 /src
parentdocker: shorten command values (diff)
downloadcimple-6295901a73828fcb9a2dd94e8bd5d59f1a5f4a91.tar.gz
cimple-6295901a73828fcb9a2dd94e8bd5d59f1a5f4a91.zip
update command names
Diffstat (limited to 'src')
-rw-r--r--src/const.h3
-rw-r--r--src/server.c11
-rw-r--r--src/worker.c9
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;