redmine

Added ability of runtime editing of "pre-exit-hook" value

... ... @@ -134,6 +134,7 @@ enum paramsource_enum {
PS_UNKNOWN = 0,
PS_ARGUMENT,
PS_CONFIG,
PS_CONTROL,
PS_DEFAULTS,
};
typedef enum paramsource_enum paramsource_t;
... ...
... ... @@ -27,6 +27,7 @@
#include "indexes.h"
#include "main.h"
#include "ctx.h"
#include "error.h"
#include "sync.h"
... ... @@ -64,6 +65,16 @@ int control_procclsyncsock(socket_sockthreaddata_t *arg, sockcmd_t *sockcmd_p) {
case SOCKCMD_REQUEST_INFO:
rc = socket_send(clsyncsock_p, SOCKCMD_REPLY_INFO, ctx_p->config_block, ctx_p->label, ctx_p->flags, ctx_p->flags_set);
break;
case SOCKCMD_REQUEST_SET: {
sockcmd_dat_set_t *dat = sockcmd_p->data;
rc = ctx_set(ctx_p, dat->key, dat->value);
if (rc) {
control_error(clsyncsock_p, "ctx_set", dat->key);
break;
}
rc = socket_send(clsyncsock_p, SOCKCMD_REPLY_SET);
break;
}
case SOCKCMD_REQUEST_DIE:
rc = sync_term(SIGTERM);
break;
... ...
This diff is collapsed. Click to expand it.
... ... @@ -19,6 +19,7 @@
extern int main_rehash(ctx_t *ctx_p);
extern int main_status_update(ctx_t *ctx_p, state_t state);
extern int ctx_set(ctx_t *ctx_p, const char *const parameter_name, const char *const parameter_value);
extern char *parameter_expand(
ctx_t *ctx_p,
char *arg,
... ...
... ... @@ -68,6 +68,7 @@ static char *recv_ptrs[SOCKET_MAX];
const char *const textmessage_args[SOCKCMD_MAXID] = {
[SOCKCMD_REQUEST_NEGOTIATION] = "%u",
[SOCKCMD_REQUEST_DUMP] = "%s",
[SOCKCMD_REQUEST_SET] = "%s\003/ %s\003/",
[SOCKCMD_REPLY_NEGOTIATION] = "%u",
[SOCKCMD_REPLY_ACK] = "%03u %lu",
[SOCKCMD_REPLY_EINVAL] = "%03u %lu",
... ... @@ -91,6 +92,7 @@ const char *const textmessage_descr[SOCKCMD_MAXID] = {
[SOCKCMD_REPLY_BYE] = "Bye.",
[SOCKCMD_REPLY_VERSION] = "clsync v%u.%u%s",
[SOCKCMD_REPLY_INFO] = "config_block == \"%s\"; label == \"%s\"; flags == %x; flags_set == %x.",
[SOCKCMD_REPLY_SET] = "Set",
[SOCKCMD_REPLY_DUMP] = "Ready",
[SOCKCMD_REPLY_UNKNOWNCMD] = "Unknown command.",
[SOCKCMD_REPLY_INVALIDCMDID] = "Invalid command id. Required: 0 <= cmd_id < 1000.",
... ... @@ -371,6 +373,9 @@ static inline int parse_text_data(sockcmd_t *sockcmd_p, char *args, size_t args_
case SOCKCMD_REQUEST_DUMP:
PARSE_TEXT_DATA_SSCANF(sockcmd_dat_dump_t, &d->dir_path);
break;
case SOCKCMD_REQUEST_SET:
PARSE_TEXT_DATA_SSCANF(sockcmd_dat_set_t, &d->key, &d->value);
break;
case SOCKCMD_REPLY_ACK:
PARSE_TEXT_DATA_SSCANF(sockcmd_dat_ack_t, &d->cmd_id, &d->cmd_num);
break;
... ...
... ... @@ -88,17 +88,19 @@ enum sockcmd_id {
SOCKCMD_REPLY_EEXIST = 163,
SOCKCMD_REPLY_EPERM = 164,
SOCKCMD_REPLY_ECUSTOM = 199,
SOCKCMD_REQUEST_LOGIN = 200,
SOCKCMD_REQUEST_VERSION = 201,
SOCKCMD_REQUEST_INFO = 202,
SOCKCMD_REQUEST_DUMP = 203,
SOCKCMD_REQUEST_DIE = 210,
SOCKCMD_REQUEST_VERSION = 200,
SOCKCMD_REQUEST_INFO = 201,
SOCKCMD_REQUEST_DUMP = 202,
SOCKCMD_REQUEST_LOGIN = 210,
SOCKCMD_REQUEST_SET = 211,
SOCKCMD_REQUEST_DIE = 240,
SOCKCMD_REQUEST_QUIT = 250,
SOCKCMD_REPLY_LOGIN = 300,
SOCKCMD_REPLY_VERSION = 301,
SOCKCMD_REPLY_INFO = 302,
SOCKCMD_REPLY_DUMP = 303,
SOCKCMD_REPLY_DIE = 310,
SOCKCMD_REPLY_VERSION = 300,
SOCKCMD_REPLY_INFO = 301,
SOCKCMD_REPLY_DUMP = 302,
SOCKCMD_REPLY_LOGIN = 310,
SOCKCMD_REPLY_SET = 311,
SOCKCMD_REPLY_DIE = 340,
SOCKCMD_REPLY_BYE = 350,
SOCKCMD_REPLY_UNEXPECTEDEND = 351,
SOCKCMD_MAXID
... ... @@ -156,6 +158,12 @@ struct sockcmd_dat_eperm {
};
typedef struct sockcmd_dat_eperm sockcmd_dat_eperm_t;
struct sockcmd_dat_set {
char key[BUFSIZ];
char value[BUFSIZ];
};
typedef struct sockcmd_dat_set sockcmd_dat_set_t;
struct sockcmd {
uint64_t cmd_num;
uint16_t cmd_id;
... ...