From 689e97c3be60bfd9258f8579884f95317ce6c630 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 17 Feb 2022 15:04:44 +0100 Subject: [PATCH 01/30] gpu-setup: Use flock Currently the script assumes that it is not called multiple times in parallel. This is not true, because for `gpu-setup job-init` it is called by the forked user process. Use flock to avoid GPU allocation races. --- helper/gpu-setup | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/helper/gpu-setup b/helper/gpu-setup index a62abf0d..e2aff83c 100755 --- a/helper/gpu-setup +++ b/helper/gpu-setup @@ -179,13 +179,11 @@ job_init() { pid=$1 uid=$2 - # we have no locking here, but mxqd is single-threaded - test -d /dev/shm/mxqd/gpu_devs || die "$0: Not initialized (no dir /dev/shm/mxqd/gpu_devs)" shopt -s nullglob for d in /dev/shm/mxqd/gpu_devs/???; do - if [ ! -e $d/pid ]; then + if pid=$pid f=$d/pid flock $d/pid -c 'test -s $f && exit 1; echo $pid>$f'; then for f in $(cat $d/access-files); do case $f in /dev/nvidia-caps/nvidia-cap*) @@ -198,7 +196,6 @@ job_init() { ;; esac done - echo $pid > $d/pid cat $d/uuid exit fi From 4e41689e2a659624441aad7a07586e22e5b6778e Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 17 Feb 2022 15:09:30 +0100 Subject: [PATCH 02/30] gpu-setup: Tolerate empty pid files and pid file removal Because `gpu-setup job-init` is asynchronous to mxqd (see previous commit), `gpu-setup job-relaese` races with it, too. Tolerate empty pid files as well as a pid files being removed away from under us. --- helper/gpu-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/gpu-setup b/helper/gpu-setup index e2aff83c..da19fd76 100755 --- a/helper/gpu-setup +++ b/helper/gpu-setup @@ -210,7 +210,7 @@ job_release() { test -d /dev/shm/mxqd/gpu_devs || die "$0: Not initialized (no dir /dev/shm/mxqd/gpu_devs)" for d in /dev/shm/mxqd/gpu_devs/???; do if [ -e $d/pid ]; then - test_pid=$(cat $d/pid) + test_pid="$(cat $d/pid 2>/dev/null)" if [ "$pid" = "$test_pid" ]; then rm $d/pid for f in $(cat $d/access-files); do From 47ce32768ceffb39cb2be7ef20fb44a93f0d0ceb Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 17 Feb 2022 15:26:47 +0100 Subject: [PATCH 03/30] mxqd: Set "group initialized" message to debug level This message is rather annoying during normal operation, so set it to debug level. --- mxqd_control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqd_control.c b/mxqd_control.c index 86a53085..02fd76ee 100644 --- a/mxqd_control.c +++ b/mxqd_control.c @@ -131,7 +131,7 @@ static void _group_list_init(struct mxq_group_list *glist) || glist->jobs_max != jobs_max || glist->slots_max != slots_max || glist->memory_max != memory_max) { - mx_log_info(" group=%s(%u):%lu jobs_max=%lu slots_max=%lu memory_max=%lu slots_per_job=%lu memory_per_job_thread=%Lf :: group %sinitialized.", + mx_log_debug(" group=%s(%u):%lu jobs_max=%lu slots_max=%lu memory_max=%lu slots_per_job=%lu memory_per_job_thread=%Lf :: group %sinitialized.", group->user_name, group->user_uid, group->group_id, From 922a46bf2fb73bb3abc2a5b80f76d3daba414a76 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 12:43:51 +0100 Subject: [PATCH 04/30] mxqadmin: Add missing initialization If the -u option is not given, passwd will not be set in the args evaluation loop, yet we use `if (!passwd) {` later in the code. Initialze pointer. --- mxqadmin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqadmin.c b/mxqadmin.c index a6632c18..3702204f 100644 --- a/mxqadmin.c +++ b/mxqadmin.c @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) struct mx_mysql *mysql = NULL; uid_t ruid, euid, suid; - struct passwd *passwd; + struct passwd *passwd = NULL; int res; From 7bd4b2207b2dc6ea69cf89c4403f948a0314e94f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 13:13:43 +0100 Subject: [PATCH 05/30] mxqkill: Add missing initialization If the -u option is not given, passwd will not be set in the args evaluation loop, yet we use `if (!passwd) {` later in the code. Initialze pointer. --- mxqkill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqkill.c b/mxqkill.c index 7b0d25e4..65d1e96a 100644 --- a/mxqkill.c +++ b/mxqkill.c @@ -238,7 +238,7 @@ int main(int argc, char *argv[]) struct mxq_group group; uid_t ruid, euid, suid; - struct passwd *passwd; + struct passwd *passwd = NULL; int res; From e58f37c96013997de25061b9ab5b68c3d9348040 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 12:56:22 +0100 Subject: [PATCH 06/30] mx_proc: Add missing initialization If pid 1 is not found in the loop, `pid1` will be left unititialized, yet it is evaluated in `if (!pid1)` after the loop. Add missing initialization. --- mx_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mx_proc.c b/mx_proc.c index 4edc2b2a..16c71f33 100644 --- a/mx_proc.c +++ b/mx_proc.c @@ -317,7 +317,7 @@ static struct mx_proc_tree_node *mx_proc_tree_add(struct mx_proc_tree *pt, struc static void mx_proc_tree_reorder_roots(struct mx_proc_tree *pt) { struct mx_proc_tree_node *current; - struct mx_proc_tree_node *pid1; + struct mx_proc_tree_node *pid1 = NULL; struct mx_proc_tree_node *last = NULL; struct mx_proc_tree_node *next = NULL; From 76a828707e6fa2fb9c859f430a4db4a542d42fff Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 09:42:57 +0100 Subject: [PATCH 07/30] tree: Remove "inline" function attributes Remove "inline" function attributes and leave the decision to the compiler. Note: We keep "inline" in the cleanup functions in mx_util.h to avoid conflicts between instances of the functions bodies in multiple compilation units. --- mx_flock.c | 6 +++--- mx_mysql.c | 52 ++++++++++++++++++++++++++-------------------------- mx_util.c | 26 +++++++++++++------------- mxq_group.c | 6 +++--- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/mx_flock.c b/mx_flock.c index ef4d3ede..5f90999b 100644 --- a/mx_flock.c +++ b/mx_flock.c @@ -21,7 +21,7 @@ # define mx_free_null(a) do { free((a)); (a) = NULL; } while(0) #endif -static inline int _flock_open(struct mx_flock *lock, mode_t mode) +static int _flock_open(struct mx_flock *lock, mode_t mode) { int fd; @@ -39,7 +39,7 @@ static inline int _flock_open(struct mx_flock *lock, mode_t mode) return fd; } -static inline int _flock_close(struct mx_flock *lock) +static int _flock_close(struct mx_flock *lock) { int res; @@ -53,7 +53,7 @@ static inline int _flock_close(struct mx_flock *lock) return res; } -static inline void _flock_free(struct mx_flock *lock) +static void _flock_free(struct mx_flock *lock) { if (!lock) return; diff --git a/mx_mysql.c b/mx_mysql.c index b54fe111..e4647b40 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -48,7 +48,7 @@ /**********************************************************************/ -static inline int mx__mysql_errno(struct mx_mysql *mysql) +static int mx__mysql_errno(struct mx_mysql *mysql) { unsigned int error; @@ -62,7 +62,7 @@ static inline int mx__mysql_errno(struct mx_mysql *mysql) return (int)error; } -extern inline const char *mx__mysql_error(struct mx_mysql *mysql) +extern const char *mx__mysql_error(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -71,7 +71,7 @@ extern inline const char *mx__mysql_error(struct mx_mysql *mysql) return mysql_error(mysql->mysql); } -extern inline const char *mx__mysql_sqlstate(struct mx_mysql *mysql) +extern const char *mx__mysql_sqlstate(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -80,7 +80,7 @@ extern inline const char *mx__mysql_sqlstate(struct mx_mysql *mysql) return mysql_sqlstate(mysql->mysql); } -static inline int mx__mysql_stmt_errno(struct mx_mysql_stmt *stmt) +static int mx__mysql_stmt_errno(struct mx_mysql_stmt *stmt) { unsigned int error; @@ -94,7 +94,7 @@ static inline int mx__mysql_stmt_errno(struct mx_mysql_stmt *stmt) return (int)error; } -static inline const char *mx__mysql_stmt_error(struct mx_mysql_stmt *stmt) +static const char *mx__mysql_stmt_error(struct mx_mysql_stmt *stmt) { mx_assert_return_NULL(stmt, EINVAL); mx_assert_return_NULL(stmt->stmt, EBADF); @@ -103,7 +103,7 @@ static inline const char *mx__mysql_stmt_error(struct mx_mysql_stmt *stmt) return mysql_stmt_error(stmt->stmt); } -static inline const char *mx__mysql_stmt_sqlstate(struct mx_mysql_stmt *stmt) +static const char *mx__mysql_stmt_sqlstate(struct mx_mysql_stmt *stmt) { mx_assert_return_NULL(stmt, EINVAL); mx_assert_return_NULL(stmt->stmt, EBADF); @@ -112,7 +112,7 @@ static inline const char *mx__mysql_stmt_sqlstate(struct mx_mysql_stmt *stmt) return mysql_stmt_sqlstate(stmt->stmt); } -static inline int mx__mysql_init(struct mx_mysql *mysql) +static int mx__mysql_init(struct mx_mysql *mysql) { mx_assert_return_minus_errno(mysql, EINVAL); mx_assert_return_minus_errno(!mysql->mysql, EUCLEAN); @@ -129,7 +129,7 @@ static inline int mx__mysql_init(struct mx_mysql *mysql) return -errno; } -static inline int mx__mysql_options(struct mx_mysql *mysql, enum mysql_option option, const void *arg) +static int mx__mysql_options(struct mx_mysql *mysql, enum mysql_option option, const void *arg) { int res; @@ -189,7 +189,7 @@ static int mx__mysql_real_connect(struct mx_mysql *mysql, const char *host, cons return -(errno=EBADE); } -static inline int mx__mysql_ping(struct mx_mysql *mysql) +static int mx__mysql_ping(struct mx_mysql *mysql) { mx_assert_return_minus_errno(mysql, EINVAL); mx_assert_return_minus_errno(mysql->mysql, EBADF); @@ -688,7 +688,7 @@ static int mx__mysql_library_end(void) { /**********************************************************************/ -extern inline int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +extern int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { mx_assert_return_minus_errno(b, EINVAL); mx_assert_return_minus_errno(value, EINVAL); @@ -747,7 +747,7 @@ void _mx_mysql_bind_dump(struct mx_mysql_bind *b) } -static inline int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) +static int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) { mx_assert_return_minus_errno(b, EINVAL); mx_assert_return_minus_errno(value, EINVAL); @@ -786,7 +786,7 @@ static inline int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int in return 0; } -static inline int _mx_mysql_bind_validate(struct mx_mysql_bind *b) +static int _mx_mysql_bind_validate(struct mx_mysql_bind *b) { int i; @@ -1230,7 +1230,7 @@ int mx_mysql_statement_field_count(struct mx_mysql_stmt *stmt) return mx__mysql_stmt_field_count(stmt); } -extern inline int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) +extern int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1240,7 +1240,7 @@ extern inline int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) return 0; } -inline int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) +int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(count, EINVAL); @@ -1251,7 +1251,7 @@ inline int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned lo return 0; } -extern inline int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) +extern int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1261,7 +1261,7 @@ extern inline int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) return 0; } -inline int mx_mysql_stmt_param_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) +int mx_mysql_stmt_param_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(count, EINVAL); @@ -1502,7 +1502,7 @@ int mx_mysql_statement_close_no_bind_cleanup(struct mx_mysql_stmt **stmt) return 0; } -extern inline int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +extern int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { int res; @@ -1514,7 +1514,7 @@ extern inline int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int in return res; } -inline int mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) +int mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) { int res; @@ -1527,42 +1527,42 @@ inline int mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, cha } -inline int mx_mysql_bind_int8(struct mx_mysql_bind *b, unsigned int index, int8_t *value) +int mx_mysql_bind_int8(struct mx_mysql_bind *b, unsigned int index, int8_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_TINY, 0); } -inline int mx_mysql_bind_uint8(struct mx_mysql_bind *b, unsigned int index, uint8_t *value) +int mx_mysql_bind_uint8(struct mx_mysql_bind *b, unsigned int index, uint8_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_TINY, 1); } -inline int mx_mysql_bind_int16(struct mx_mysql_bind *b, unsigned int index, int16_t *value) +int mx_mysql_bind_int16(struct mx_mysql_bind *b, unsigned int index, int16_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_SHORT, 0); } -inline int mx_mysql_bind_uint16(struct mx_mysql_bind *b, unsigned int index, uint16_t *value) +int mx_mysql_bind_uint16(struct mx_mysql_bind *b, unsigned int index, uint16_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_SHORT, 1); } -inline int mx_mysql_bind_int32(struct mx_mysql_bind *b, unsigned int index, int32_t *value) +int mx_mysql_bind_int32(struct mx_mysql_bind *b, unsigned int index, int32_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_LONG, 0); } -inline int mx_mysql_bind_uint32(struct mx_mysql_bind *b, unsigned int index, uint32_t *value) +int mx_mysql_bind_uint32(struct mx_mysql_bind *b, unsigned int index, uint32_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_LONG, 1); } -inline int mx_mysql_bind_int64(struct mx_mysql_bind *b, unsigned int index, int64_t *value) +int mx_mysql_bind_int64(struct mx_mysql_bind *b, unsigned int index, int64_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_LONGLONG, 0); } -inline int mx_mysql_bind_uint64(struct mx_mysql_bind *b, unsigned int index, uint64_t *value) +int mx_mysql_bind_uint64(struct mx_mysql_bind *b, unsigned int index, uint64_t *value) { return mx_mysql_bind_integer(b, index, (void *)value, MYSQL_TYPE_LONGLONG, 1); } diff --git a/mx_util.c b/mx_util.c index b693ab6d..c1d5f314 100644 --- a/mx_util.c +++ b/mx_util.c @@ -20,7 +20,7 @@ #include "mx_log.h" #include "mx_util.h" -static inline int _mx_strbeginswith(char *str, const char *start, char **endptr, short ignore_case) +static int _mx_strbeginswith(char *str, const char *start, char **endptr, short ignore_case) { size_t len; int res; @@ -42,17 +42,17 @@ static inline int _mx_strbeginswith(char *str, const char *start, char **endptr, return 1; } -inline int mx_strbeginswith(char *str, const char *start, char **endptr) +int mx_strbeginswith(char *str, const char *start, char **endptr) { return _mx_strbeginswith(str, start, endptr, 0); } -inline int mx_stribeginswith(char *str, const char *start, char **endptr) +int mx_stribeginswith(char *str, const char *start, char **endptr) { return _mx_strbeginswith(str, start, endptr, 1); } -static inline int _mx_strbeginswithany(char *str, char **starts, char **endptr, short ignore_case) +static int _mx_strbeginswithany(char *str, char **starts, char **endptr, short ignore_case) { char **s; char *end; @@ -73,7 +73,7 @@ static inline int _mx_strbeginswithany(char *str, char **starts, char **endptr, return 0; } -inline int mx_strbeginswithany(char *str, char **starts, char **endptr) +int mx_strbeginswithany(char *str, char **starts, char **endptr) { return _mx_strbeginswithany(str, starts, endptr, 0); } @@ -83,7 +83,7 @@ int mx_stribeginswithany(char *str, char **starts, char **endptr) return _mx_strbeginswithany(str, starts, endptr, 1); } -inline int mx_strtobytes(char *str, unsigned long long int *bytes) +int mx_strtobytes(char *str, unsigned long long int *bytes) { unsigned long long int s = 0; unsigned long long int t; @@ -149,7 +149,7 @@ inline int mx_strtobytes(char *str, unsigned long long int *bytes) return 0; } -inline int mx_strtoseconds(char *str, unsigned long long int *seconds) +int mx_strtoseconds(char *str, unsigned long long int *seconds) { unsigned long long int s = 0; unsigned long long int t; @@ -219,7 +219,7 @@ inline int mx_strtoseconds(char *str, unsigned long long int *seconds) return 0; } -inline int mx_strtominutes(char *str, unsigned long long int *minutes) +int mx_strtominutes(char *str, unsigned long long int *minutes) { int res; @@ -231,7 +231,7 @@ inline int mx_strtominutes(char *str, unsigned long long int *minutes) return res; } -inline char *mx_strskipwhitespaces(char *str) +char *mx_strskipwhitespaces(char *str) { char *s; @@ -245,7 +245,7 @@ inline char *mx_strskipwhitespaces(char *str) /* wrapper unsigned */ -inline int mx_strtoul(char *str, unsigned long int *to) +int mx_strtoul(char *str, unsigned long int *to) { unsigned long int ul; char *end; @@ -273,7 +273,7 @@ inline int mx_strtoul(char *str, unsigned long int *to) return 0; } -inline int mx_strtoull(char *str, unsigned long long int *to) +int mx_strtoull(char *str, unsigned long long int *to) { unsigned long long int ull; char *end; @@ -303,7 +303,7 @@ inline int mx_strtoull(char *str, unsigned long long int *to) /* wrapper signed */ -inline int mx_strtol(char *str, signed long int *to) +int mx_strtol(char *str, signed long int *to) { long int l; char *end; @@ -328,7 +328,7 @@ inline int mx_strtol(char *str, signed long int *to) return 0; } -inline int mx_strtoll(char *str, signed long long int *to) +int mx_strtoll(char *str, signed long long int *to) { long long int ll; char *end; diff --git a/mxq_group.c b/mxq_group.c index 92cd4084..bb82712e 100644 --- a/mxq_group.c +++ b/mxq_group.c @@ -126,7 +126,7 @@ void mxq_group_free_content(struct mxq_group *g) } -extern inline uint64_t mxq_group_jobs_done(struct mxq_group *g) +extern uint64_t mxq_group_jobs_done(struct mxq_group *g) { uint64_t done = 0; @@ -138,7 +138,7 @@ extern inline uint64_t mxq_group_jobs_done(struct mxq_group *g) return done; } -extern inline uint64_t mxq_group_jobs_active(struct mxq_group *g) +extern uint64_t mxq_group_jobs_active(struct mxq_group *g) { uint64_t active; @@ -152,7 +152,7 @@ extern inline uint64_t mxq_group_jobs_active(struct mxq_group *g) return active; } -extern inline uint64_t mxq_group_jobs_inq(struct mxq_group *g) +extern uint64_t mxq_group_jobs_inq(struct mxq_group *g) { uint64_t inq; From 69f9f1ca2db8543279db4818932ed9e7ff1c7dd5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 09:49:46 +0100 Subject: [PATCH 08/30] tree: Remove "extern" function attributes Remove "extern" keyword from functions, because it has no effect. --- mx_mysql.c | 12 ++++++------ mxq_group.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mx_mysql.c b/mx_mysql.c index e4647b40..cb20f841 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -62,7 +62,7 @@ static int mx__mysql_errno(struct mx_mysql *mysql) return (int)error; } -extern const char *mx__mysql_error(struct mx_mysql *mysql) +const char *mx__mysql_error(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -71,7 +71,7 @@ extern const char *mx__mysql_error(struct mx_mysql *mysql) return mysql_error(mysql->mysql); } -extern const char *mx__mysql_sqlstate(struct mx_mysql *mysql) +const char *mx__mysql_sqlstate(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -688,7 +688,7 @@ static int mx__mysql_library_end(void) { /**********************************************************************/ -extern int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { mx_assert_return_minus_errno(b, EINVAL); mx_assert_return_minus_errno(value, EINVAL); @@ -1230,7 +1230,7 @@ int mx_mysql_statement_field_count(struct mx_mysql_stmt *stmt) return mx__mysql_stmt_field_count(stmt); } -extern int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) +int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1251,7 +1251,7 @@ int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned long *cou return 0; } -extern int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) +int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1502,7 +1502,7 @@ int mx_mysql_statement_close_no_bind_cleanup(struct mx_mysql_stmt **stmt) return 0; } -extern int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { int res; diff --git a/mxq_group.c b/mxq_group.c index bb82712e..0ef68a97 100644 --- a/mxq_group.c +++ b/mxq_group.c @@ -126,7 +126,7 @@ void mxq_group_free_content(struct mxq_group *g) } -extern uint64_t mxq_group_jobs_done(struct mxq_group *g) +uint64_t mxq_group_jobs_done(struct mxq_group *g) { uint64_t done = 0; @@ -138,7 +138,7 @@ extern uint64_t mxq_group_jobs_done(struct mxq_group *g) return done; } -extern uint64_t mxq_group_jobs_active(struct mxq_group *g) +uint64_t mxq_group_jobs_active(struct mxq_group *g) { uint64_t active; @@ -152,7 +152,7 @@ extern uint64_t mxq_group_jobs_active(struct mxq_group *g) return active; } -extern uint64_t mxq_group_jobs_inq(struct mxq_group *g) +uint64_t mxq_group_jobs_inq(struct mxq_group *g) { uint64_t inq; From 2cbc3e884dbc18ffdac16d45ba6f499b9123bd63 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:15:35 +0100 Subject: [PATCH 09/30] mx_getopt: Remove dead code --- mx_getopt.c | 18 ------------------ mx_getopt.h | 4 ---- 2 files changed, 22 deletions(-) diff --git a/mx_getopt.c b/mx_getopt.c index a92e3650..8d8ddcb1 100644 --- a/mx_getopt.c +++ b/mx_getopt.c @@ -396,11 +396,6 @@ static int _mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex) return handle_option(optctl, idx); } -int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex) -{ - return _mx_getopt_long(optctl, optindex); -} - int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex) { int opt; @@ -455,16 +450,3 @@ int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex) return opt; } - -void mx_getopt_print_quoted(char *s) -{ - putchar('\''); - while (*s) { - if (*s == '\'') - printf("'\\''"); - else - putchar(*s); - s++; - } - putchar('\''); -} diff --git a/mx_getopt.h b/mx_getopt.h index fe9ef256..4fc09c92 100644 --- a/mx_getopt.h +++ b/mx_getopt.h @@ -179,9 +179,5 @@ struct mx_getopt_ctl { void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl); int mx_getopt_init(struct mx_getopt_ctl *ctl, int argc, char **argv, struct mx_option *optv); -int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex); int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex); - -void mx_getopt_print_quoted(char *s); - #endif From 50a8a3dddcd22f1d8b60e69d28bda32d19d5bb0b Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:15:45 +0100 Subject: [PATCH 10/30] mx_mysql: Remove dead code --- mx_mysql.c | 167 ----------------------------------------------------- mx_mysql.h | 6 -- 2 files changed, 173 deletions(-) diff --git a/mx_mysql.c b/mx_mysql.c index cb20f841..4fce8ac5 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -230,45 +230,6 @@ static int mx__mysql_ping(struct mx_mysql *mysql) return -(errno=EBADE); } -static int mx__mysql_real_query(struct mx_mysql *mysql, const char *stmt_str, unsigned long length) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - mx_assert_return_minus_errno(stmt_str, EINVAL); - mx_assert_return_minus_errno(*stmt_str, EINVAL); - - mx_assert_return_minus_errno(mysql->mysql, EBADF); - - int res; - - if (!length) - length = strlen(stmt_str); - - mysql->func = "mysql_real_query"; - res = mysql_real_query(mysql->mysql, stmt_str, length); - - if (res == 0) - return 0; - - mx__mysql_log_warning(mysql); - - switch (mx__mysql_errno(mysql)) { - case CR_COMMANDS_OUT_OF_SYNC: - mx__mysql_log_emerg(mysql); - return -(errno=EPROTO); - - case CR_SERVER_GONE_ERROR: - case CR_SERVER_LOST: - return -(errno=EAGAIN); - - case CR_UNKNOWN_ERROR: - return -(errno=EIO); - } - - mx__mysql_log_emerg(mysql); - mx_log_emerg("ERROR: mysql_real_query() returned undefined error number: %d", mx__mysql_errno(mysql)); - return -(errno=EBADE); -} - static int mx__mysql_stmt_init(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); @@ -591,22 +552,6 @@ static int mx__mysql_stmt_field_count(struct mx_mysql_stmt *stmt) return (int)count; } -static int mx__mysql_stmt_num_rows(struct mx_mysql_stmt *stmt, unsigned long long *count) -{ - my_ulonglong c; - - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - stmt->func = "mysql_stmt_num_rows"; - c = mysql_stmt_num_rows(stmt->stmt); - - *count = (unsigned long long)c; - - /* no mysql errors possible */ - return 0; -} - static int mx__mysql_stmt_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long *count) { my_ulonglong c; @@ -711,42 +656,6 @@ int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *va return 0; } -void _mx_mysql_bind_dump_index(struct mx_mysql_bind *b, unsigned int index) -{ - mx_debug_value("%d", index); - mx_debug_value("%d", b->bind[index].buffer_type); - mx_debug_value("%lu", b->bind[index].buffer_length); - mx_debug_value("%p", b->bind[index].buffer); - if (b->bind[index].buffer_type == MYSQL_TYPE_STRING) - mx_debug_value("%s", (char *)b->bind[index].buffer); - mx_debug_value("%d", b->bind[index].is_unsigned); - mx_debug_value("%lu", *b->bind[index].length); - mx_debug_value("%d", *b->bind[index].is_null); - mx_debug_value("%d", *b->bind[index].error); - mx_debug_value("0x%x", b->data[index].flags); -} - -void _mx_mysql_bind_dump(struct mx_mysql_bind *b) -{ - int i; - - mx_log_debug("entered"); - - if (!b) { - mx_log_debug("done"); - return; - } - - mx_debug_value("%d", b->type); - mx_debug_value("%lu", b->count); - - for (i=0; i < b->count; i++) { - _mx_mysql_bind_dump_index(b, i); - } - mx_log_debug("done"); -} - - static int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, char **value) { mx_assert_return_minus_errno(b, EINVAL); @@ -857,12 +766,6 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname) return 0; } -char *mx_mysql_option_get_default_file(struct mx_mysql *mysql) -{ - mx_assert_return_NULL(mysql, EINVAL); - return mysql->default_file; -} - int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group) { mx_assert_return_minus_errno(mysql, EINVAL); @@ -875,13 +778,6 @@ int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group) return 0; } -char *mx_mysql_option_get_default_group(struct mx_mysql *mysql) -{ - mx_assert_return_NULL(mysql, EINVAL); - - return mysql->default_group; -} - int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect) { mx_assert_return_minus_errno(mysql, EINVAL); @@ -890,13 +786,6 @@ int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect) return 0; } -int mx_mysql_option_get_reconnect(struct mx_mysql *mysql) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - - return (int)mysql->reconnect; -} - static int mx_mysql_real_connect(struct mx_mysql *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag) { int res; @@ -1044,32 +933,6 @@ int mx_mysql_ping_forever(struct mx_mysql *mysql) return res; } - -int mx_mysql_queryf(struct mx_mysql *mysql, const char *fmt, ...) -{ - mx_assert_return_minus_errno(mysql, EINVAL); - mx_assert_return_minus_errno(fmt, EINVAL); - mx_assert_return_minus_errno(*fmt, EINVAL); - - mx_assert_return_minus_errno(mysql->mysql, EBADF); - - va_list ap; - _mx_cleanup_free_ char *query = NULL; - int res; - size_t len; - - va_start(ap, fmt); - len = vasprintf(&query, fmt, ap); - va_end(ap); - - if (len == -1) - return 0; - - res = mx__mysql_real_query(mysql, query, len); - - return res; -} - int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) { struct mx_mysql_stmt *s; @@ -1146,14 +1009,6 @@ int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long return mx__mysql_stmt_insert_id(stmt, id); } -int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { - return mx__mysql_stmt_affected_rows(stmt, count); -} - -int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { - return mx__mysql_stmt_num_rows(stmt, count); -} - int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt) { struct mx_mysql_bind *r; @@ -1240,17 +1095,6 @@ int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_stmt_field_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) -{ - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(count, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - *count = stmt->field_count; - - return 0; -} - int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); @@ -1261,17 +1105,6 @@ int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_stmt_param_count_get(struct mx_mysql_stmt *stmt, unsigned long *count) -{ - mx_assert_return_minus_errno(stmt, EINVAL); - mx_assert_return_minus_errno(count, EINVAL); - mx_assert_return_minus_errno(stmt->stmt, EBADF); - - *count = stmt->param_count; - - return 0; -} - int mx_mysql_bind_cleanup(struct mx_mysql_bind *bind) { if (!bind) diff --git a/mx_mysql.h b/mx_mysql.h index cfec0040..22817335 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -106,10 +106,6 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname); int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group); int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect); -char *mx_mysql_option_get_default_file(struct mx_mysql *mysql); -char *mx_mysql_option_get_default_group(struct mx_mysql *mysql); -int mx_mysql_option_get_reconnect(struct mx_mysql *mysql); - int mx_mysql_connect(struct mx_mysql **mysql); int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds); #define mx_mysql_connect_forever(m) mx_mysql_connect_forever_sec((m), MX_MYSQL_FAIL_WAIT_DEFAULT) @@ -139,8 +135,6 @@ struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql * int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id); -int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); -int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt); From 09da26443e7bf744fc561c46c0555778844d2805 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:15:56 +0100 Subject: [PATCH 11/30] mx_daemon: Remove dead code --- mxq_daemon.c | 166 --------------------------------------------------- mxq_daemon.h | 1 - 2 files changed, 167 deletions(-) diff --git a/mxq_daemon.c b/mxq_daemon.c index 2904c70f..9fea495b 100644 --- a/mxq_daemon.c +++ b/mxq_daemon.c @@ -46,57 +46,6 @@ #define _to_string(s) #s #define status_str(x) _to_string(x) -static int bind_result_daemon_fields(struct mx_mysql_bind *result, struct mxq_daemon *daemon) -{ - int res = 0; - int idx = 0; - - res = mx_mysql_bind_init_result(result, DAEMON_FIELDS_CNT); - assert(res >= 0); - - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_id)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->daemon_name)); - res += mx_mysql_bind_var(result, idx++, uint8, &(daemon->status)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->hostname)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->mxq_version)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->boot_id)); - - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->pid_starttime)); - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_pid)); - - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_slots)); - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->daemon_memory)); - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->daemon_maxtime)); - - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->daemon_memory_limit_slot_soft)); - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->daemon_memory_limit_slot_hard)); - - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_jobs_running)); - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_slots_running)); - res += mx_mysql_bind_var(result, idx++, uint32, &(daemon->daemon_threads_running)); - res += mx_mysql_bind_var(result, idx++, uint64, &(daemon->daemon_memory_used)); - res += mx_mysql_bind_var(result, idx++, uint16, &(daemon->gpus_max)); - res += mx_mysql_bind_var(result, idx++, uint16, &(daemon->gpus_used)); - - res += mx_mysql_bind_var(result, idx++, int64, &(daemon->mtime.tv_sec)); - res += mx_mysql_bind_var(result, idx++, int64, &(daemon->daemon_start.tv_sec)); - res += mx_mysql_bind_var(result, idx++, int64, &(daemon->daemon_stop.tv_sec)); - - res += mx_mysql_bind_var(result, idx++, int32, &(daemon->daemon_flags)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->tags)); - res += mx_mysql_bind_var(result, idx++, string, &(daemon->prerequisites)); - - return res; -} - -void mxq_daemon_free_content(struct mxq_daemon *daemon) -{ - mx_free_null(daemon->daemon_name); - mx_free_null(daemon->hostname); - mx_free_null(daemon->mxq_version); - mx_free_null(daemon->boot_id); -} - int mxq_daemon_register(struct mx_mysql *mysql, struct mxq_daemon *daemon) { struct mx_mysql_stmt *stmt = NULL; @@ -363,118 +312,3 @@ int mxq_daemon_update_statistics(struct mx_mysql *mysql, struct mxq_daemon *daem return res; } - -int mxq_load_all_daemons(struct mx_mysql *mysql, struct mxq_daemon **daemons) -{ - struct mxq_daemon *daemons_tmp = NULL; - struct mxq_daemon daemon_buf = {0}; - struct mx_mysql_bind result = {0}; - int res; - - assert(mysql); - assert(daemons); - assert(!(*daemons)); - - char *query = - "SELECT" - DAEMON_FIELDS - " FROM" - " mxq_daemon"; - - res = bind_result_daemon_fields(&result, &daemon_buf); - assert(res == 0); - - res = mx_mysql_do_statement(mysql, query, NULL, &result, &daemon_buf, (void **)&daemons_tmp, sizeof(*daemons_tmp)); - if (res < 0) { - mx_log_err("mx_mysql_do_statement(): %m"); - return res; - } - - *daemons = daemons_tmp; - return res; -} - -int mxq_load_running_daemons(struct mx_mysql *mysql, struct mxq_daemon **daemons) -{ - struct mxq_daemon *daemons_tmp = NULL; - struct mxq_daemon daemon_buf = {0}; - struct mx_mysql_bind result = {0}; - int res; - - assert(mysql); - assert(daemons); - assert(!(*daemons)); - - char *query = - "SELECT" - DAEMON_FIELDS - " FROM" - " mxq_daemon" - " WHERE" - " daemon_jobs_runnning > 0" - " OR" - " daemon_stop = 0"; - - res = bind_result_daemon_fields(&result, &daemon_buf); - assert(res == 0); - - res = mx_mysql_do_statement(mysql, query, NULL, &result, &daemon_buf, (void **)&daemons_tmp, sizeof(*daemons_tmp)); - if (res < 0) { - mx_log_err("mx_mysql_do_statement(): %m"); - return res; - } - - *daemons = daemons_tmp; - return res; -} - -int mxq_load_running_daemons_by_host_and_name(struct mx_mysql *mysql, struct mxq_daemon **daemons, char *hostname, char *daemon_name) -{ - struct mxq_daemon *daemons_tmp = NULL; - struct mxq_daemon daemon_buf = {0}; - struct mx_mysql_bind result = {0}; - struct mx_mysql_bind param = {0}; - int res; - int idx; - - assert(mysql); - assert(daemons); - assert(!(*daemons)); - assert(hostname); - assert(daemon_name); - - char *query = - "SELECT" - DAEMON_FIELDS - " FROM" - " mxq_daemon" - " WHERE" - " hostname = ?" - " AND" - " daemon_name = ?" - " AND" - " (" - " daemon_jobs_runnning > 0" - " OR" - " daemon_stop = 0" - " )"; - - res = mx_mysql_bind_init_param(¶m, 2); - assert(res == 0); - idx = 0; - res = mx_mysql_bind_var(¶m, idx++, string, &hostname); - res = mx_mysql_bind_var(¶m, idx++, string, &daemon_name); - assert(res == 0); - - res = bind_result_daemon_fields(&result, &daemon_buf); - assert(res == 0); - - res = mx_mysql_do_statement(mysql, query, NULL, &result, &daemon_buf, (void **)&daemons_tmp, sizeof(*daemons_tmp)); - if (res < 0) { - mx_log_err("mx_mysql_do_statement(): %m"); - return res; - } - - *daemons = daemons_tmp; - return res; -} diff --git a/mxq_daemon.h b/mxq_daemon.h index aabcb246..006fb2c9 100644 --- a/mxq_daemon.h +++ b/mxq_daemon.h @@ -54,7 +54,6 @@ struct mxq_daemon { uint16_t gpus_used; }; -void mxq_daemon_free_content(struct mxq_daemon *daemon); int mxq_daemon_register(struct mx_mysql *mysql, struct mxq_daemon *daemon); int mxq_daemon_mark_crashed(struct mx_mysql *mysql, struct mxq_daemon *daemon); int mxq_daemon_update_statistics(struct mx_mysql *mysql, struct mxq_daemon *daemon); From 90f3a3634b9a5ff4544a16624f70073a2dac508b Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:30:41 +0100 Subject: [PATCH 12/30] tree: Convert some functions into static Turn some functions, which are only used inside a compilation unit, into static. If the funtions was published in the include file, remove it there. --- mx_getopt.c | 2 +- mx_mysql.c | 32 +++++++++++++++++--------------- mx_mysql.h | 11 ----------- mxq_group.c | 2 +- mxq_group.h | 1 - mxq_job.c | 8 ++++---- mxq_job.h | 3 --- 7 files changed, 23 insertions(+), 36 deletions(-) diff --git a/mx_getopt.c b/mx_getopt.c index 8d8ddcb1..1ef82c20 100644 --- a/mx_getopt.c +++ b/mx_getopt.c @@ -316,7 +316,7 @@ void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl) optctl->_argc--; } -void mx_getopt_pop_all_arguments(struct mx_getopt_ctl *optctl) +static void mx_getopt_pop_all_arguments(struct mx_getopt_ctl *optctl) { while(optctl->optind < optctl->_argc) mx_getopt_pop_current_argument(optctl); diff --git a/mx_mysql.c b/mx_mysql.c index 4fce8ac5..da1efebf 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -46,6 +46,8 @@ #define mx__mysql_stmt_log_info(stmt) mx__mysql_stmt_log(info, (stmt)) #define mx__mysql_stmt_log_debug(stmt) mx__mysql_stmt_log(debug, (stmt)) +static struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql *mysql, char *statement, struct mx_mysql_bind *param, struct mx_mysql_bind *result); + /**********************************************************************/ static int mx__mysql_errno(struct mx_mysql *mysql) @@ -62,7 +64,7 @@ static int mx__mysql_errno(struct mx_mysql *mysql) return (int)error; } -const char *mx__mysql_error(struct mx_mysql *mysql) +static const char *mx__mysql_error(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -71,7 +73,7 @@ const char *mx__mysql_error(struct mx_mysql *mysql) return mysql_error(mysql->mysql); } -const char *mx__mysql_sqlstate(struct mx_mysql *mysql) +static const char *mx__mysql_sqlstate(struct mx_mysql *mysql) { mx_assert_return_NULL(mysql, EINVAL); mx_assert_return_NULL(mysql->mysql, EBADF); @@ -633,7 +635,7 @@ static int mx__mysql_library_end(void) { /**********************************************************************/ -int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +static int _mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { mx_assert_return_minus_errno(b, EINVAL); mx_assert_return_minus_errno(value, EINVAL); @@ -726,7 +728,7 @@ int mx_mysql_initialize(struct mx_mysql **mysql) return 0; } -int mx_mysql_init(struct mx_mysql *mysql) +static int mx_mysql_init(struct mx_mysql *mysql) { int res; @@ -863,11 +865,11 @@ int mx_mysql_disconnect(struct mx_mysql *mysql) { return mx__mysql_close(mysql); } -int mx_mysql_end(void) { +static int mx_mysql_end(void) { return mx__mysql_library_end(); } -int mx_mysql_free(struct mx_mysql **mysql) +static int mx_mysql_free(struct mx_mysql **mysql) { mx_assert_return_minus_errno(mysql, EINVAL); mx_assert_return_minus_errno(*mysql, EBADF); @@ -900,14 +902,14 @@ int mx_mysql_finish(struct mx_mysql **mysql) } -int mx_mysql_ping(struct mx_mysql *mysql) +static int mx_mysql_ping(struct mx_mysql *mysql) { mx_assert_return_minus_errno(mysql, EINVAL); return mx__mysql_ping(mysql); } -int mx_mysql_ping_forever(struct mx_mysql *mysql) +static int mx_mysql_ping_forever(struct mx_mysql *mysql) { int res; int fail = 0; @@ -933,7 +935,7 @@ int mx_mysql_ping_forever(struct mx_mysql *mysql) return res; } -int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) +static int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) { struct mx_mysql_stmt *s; int res; @@ -1085,7 +1087,7 @@ int mx_mysql_statement_field_count(struct mx_mysql_stmt *stmt) return mx__mysql_stmt_field_count(stmt); } -int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) +static int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1095,7 +1097,7 @@ int mx_mysql_stmt_field_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) +static int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) { mx_assert_return_minus_errno(stmt, EINVAL); mx_assert_return_minus_errno(stmt->stmt, EBADF); @@ -1105,7 +1107,7 @@ int mx_mysql_stmt_param_count_set(struct mx_mysql_stmt *stmt) return 0; } -int mx_mysql_bind_cleanup(struct mx_mysql_bind *bind) +static int mx_mysql_bind_cleanup(struct mx_mysql_bind *bind) { if (!bind) return 0; @@ -1118,7 +1120,7 @@ int mx_mysql_bind_cleanup(struct mx_mysql_bind *bind) return 0; } -int mx_mysql_bind_init_from(struct mx_mysql_bind *bind, unsigned long count, enum mx_mysql_bind_type type, struct mx_mysql_bind *from) +static int mx_mysql_bind_init_from(struct mx_mysql_bind *bind, unsigned long count, enum mx_mysql_bind_type type, struct mx_mysql_bind *from) { mx_assert_return_minus_errno(bind, EINVAL); @@ -1253,7 +1255,7 @@ int mx_mysql_do_statement_retry_on_fail(struct mx_mysql *mysql, char *query, str } -struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql *mysql, char *statement, struct mx_mysql_bind *param, struct mx_mysql_bind *result) +static struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql *mysql, char *statement, struct mx_mysql_bind *param, struct mx_mysql_bind *result) { int res; struct mx_mysql_stmt *stmt = NULL; @@ -1335,7 +1337,7 @@ int mx_mysql_statement_close_no_bind_cleanup(struct mx_mysql_stmt **stmt) return 0; } -int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) +static int mx_mysql_bind_integer(struct mx_mysql_bind *b, unsigned int index, void *value, int type, int is_unsigned) { int res; diff --git a/mx_mysql.h b/mx_mysql.h index 22817335..ae5f79e4 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -98,9 +98,6 @@ struct mx_mysql_stmt { #define mx_mysql_statement_result_bind(s, i, t, p) mx_mysql_bind_var(&((s)->result), (i), t, (p)) int mx_mysql_initialize(struct mx_mysql **mysql); -int mx_mysql_init(struct mx_mysql *mysql); - -int mx_mysql_free(struct mx_mysql **mysql); int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname); int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group); @@ -112,14 +109,8 @@ int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds); int mx_mysql_disconnect(struct mx_mysql *mysql); -int mx_mysql_end(void); - int mx_mysql_finish(struct mx_mysql **mysql); -int mx_mysql_ping(struct mx_mysql *mysql); -int mx_mysql_ping_forever(struct mx_mysql *mysql); - - #define mx_mysql_do_statement_noresult(m, q, p) \ mx_mysql_do_statement(m, q, p, NULL, NULL, NULL, 0) @@ -129,9 +120,7 @@ int mx_mysql_ping_forever(struct mx_mysql *mysql); int mx_mysql_do_statement(struct mx_mysql *mysql, char *query, struct mx_mysql_bind *param, struct mx_mysql_bind *result, void *from, void **to, size_t size); int mx_mysql_do_statement_retry_on_fail(struct mx_mysql *mysql, char *query, struct mx_mysql_bind *param, struct mx_mysql_bind *result, void *from, void **to, size_t size); -int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt); struct mx_mysql_stmt *mx_mysql_statement_prepare(struct mx_mysql *mysql, char *statement); -struct mx_mysql_stmt *mx_mysql_statement_prepare_with_bindings(struct mx_mysql *mysql, char *statement, struct mx_mysql_bind *param, struct mx_mysql_bind *result); int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id); diff --git a/mxq_group.c b/mxq_group.c index 0ef68a97..3c849115 100644 --- a/mxq_group.c +++ b/mxq_group.c @@ -126,7 +126,7 @@ void mxq_group_free_content(struct mxq_group *g) } -uint64_t mxq_group_jobs_done(struct mxq_group *g) +static uint64_t mxq_group_jobs_done(struct mxq_group *g) { uint64_t done = 0; diff --git a/mxq_group.h b/mxq_group.h index 96ad904e..5eb23b2e 100644 --- a/mxq_group.h +++ b/mxq_group.h @@ -67,7 +67,6 @@ struct mxq_group { void mxq_group_free_content(struct mxq_group *g); -uint64_t mxq_group_jobs_done(struct mxq_group *g); uint64_t mxq_group_jobs_active(struct mxq_group *g); uint64_t mxq_group_jobs_inq(struct mxq_group *g); diff --git a/mxq_job.c b/mxq_job.c index 5a0041a5..08217fcb 100644 --- a/mxq_job.c +++ b/mxq_job.c @@ -279,7 +279,7 @@ int mxq_load_jobs_in_group_with_status(struct mx_mysql *mysql, struct mxq_job ** return res; } -uint64_t mxq_select_job_from_group(struct mx_mysql *mysql, uint64_t group_id) +static uint64_t mxq_select_job_from_group(struct mx_mysql *mysql, uint64_t group_id) { struct mx_mysql_bind param = {0}; struct mx_mysql_bind result = {0}; @@ -326,7 +326,7 @@ uint64_t mxq_select_job_from_group(struct mx_mysql *mysql, uint64_t group_id) return(job_id); } -int mxq_assign_job_from_group_to_daemon(struct mx_mysql *mysql, uint64_t group_id, struct mxq_daemon *daemon, unsigned long slots_per_job) +static int mxq_assign_job_from_group_to_daemon(struct mx_mysql *mysql, uint64_t group_id, struct mxq_daemon *daemon, unsigned long slots_per_job) { struct mx_mysql_bind param = {0}; int res; @@ -423,7 +423,7 @@ int mxq_unassign_jobs_of_server(struct mx_mysql *mysql, struct mxq_daemon *daemo return res; } -int mxq_set_job_status_loaded_on_server(struct mx_mysql *mysql, struct mxq_job *job) +static int mxq_set_job_status_loaded_on_server(struct mx_mysql *mysql, struct mxq_job *job) { struct mx_mysql_bind param = {0}; char *host_id; @@ -676,7 +676,7 @@ int mxq_job_set_tmpfilenames(struct mxq_group *g, struct mxq_job *j) return 1; } -int mxq_load_job_from_group_assigned_to_daemon(struct mx_mysql *mysql, struct mxq_job **jobs_result, uint64_t group_id, struct mxq_daemon *daemon) +static int mxq_load_job_from_group_assigned_to_daemon(struct mx_mysql *mysql, struct mxq_job **jobs_result, uint64_t group_id, struct mxq_daemon *daemon) { struct mxq_job *jobs_tmp = NULL; struct mx_mysql_bind param = {0}; diff --git a/mxq_job.h b/mxq_job.h index a08aa4ad..f6a9c314 100644 --- a/mxq_job.h +++ b/mxq_job.h @@ -86,14 +86,11 @@ void mxq_job_free_content(struct mxq_job *j); int mxq_load_job(struct mx_mysql *mysql, struct mxq_job **mxq_jobs, uint64_t job_id); int mxq_load_jobs_in_group(struct mx_mysql *mysql, struct mxq_job **mxq_jobs, struct mxq_group *grp); int mxq_load_jobs_in_group_with_status(struct mx_mysql *mysql, struct mxq_job **mxq_jobs, struct mxq_group *grp, uint64_t job_status); -int mxq_assign_job_from_group_to_daemon(struct mx_mysql *mysql, uint64_t group_id, struct mxq_daemon *daemon, unsigned long slots_per_job); int mxq_unassign_jobs_of_server(struct mx_mysql *mysql, struct mxq_daemon *daemon); -int mxq_set_job_status_loaded_on_server(struct mx_mysql *mysql, struct mxq_job *job); int mxq_set_job_status_running(struct mx_mysql *mysql, struct mxq_job *job); int mxq_set_job_status_exited(struct mx_mysql *mysql, struct mxq_job *job); int mxq_set_job_status_unknown(struct mx_mysql *mysql, struct mxq_job *job); int mxq_job_set_tmpfilenames(struct mxq_group *g, struct mxq_job *j); -int mxq_load_job_from_group_assigned_to_daemon(struct mx_mysql *mysql, struct mxq_job **jobs_result, uint64_t group_id, struct mxq_daemon *daemon); int mxq_load_job_from_group_for_daemon(struct mx_mysql *mysql, struct mxq_job *mxqjob, uint64_t group_id, struct mxq_daemon *daemon,unsigned long slots_per_job); int mxq_load_jobs_running_on_server(struct mx_mysql *mysql, struct mxq_job **jobs_result, struct mxq_daemon *daemon); int mxq_unload_job_from_server(struct mx_mysql *mysql, struct mxq_daemon *daemon, uint64_t job_id); From ea504b4b764dafc2440fe96f04baf96d26a6cc7f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:37:15 +0100 Subject: [PATCH 13/30] tree; Remove dead stores --- mx_log.c | 6 +----- mx_proc.c | 2 -- mxqps.c | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/mx_log.c b/mx_log.c index 6a6a5b53..9e27bd3a 100644 --- a/mx_log.c +++ b/mx_log.c @@ -64,7 +64,6 @@ int mx_log_printf(const char *fmt, ...) { int len; int len2; - int res; char *msg = NULL; va_list ap; @@ -84,15 +83,12 @@ int mx_log_printf(const char *fmt, ...) } len2 = fprintf(stderr, "%s\n", msg); - res = fflush(stderr); + fflush(stderr); mx_free_null(msg); if (len2 != len+1) return -(errno=EIO); - if (!res) - res = 0; - return len; } diff --git a/mx_proc.c b/mx_proc.c index 16c71f33..67ecb2e2 100644 --- a/mx_proc.c +++ b/mx_proc.c @@ -224,8 +224,6 @@ static struct mx_proc_tree_node *mx_proc_tree_find_by_pid(struct mx_proc_tree_no if (pid == 0) return NULL; - current = ptn; - for (current = ptn; current; current=current->next) { if (current->pinfo.pstat->pid == pid) return current; diff --git a/mxqps.c b/mxqps.c index 5088edc0..2e956a85 100644 --- a/mxqps.c +++ b/mxqps.c @@ -26,9 +26,6 @@ int mx_proc_tree_node_print_debug(struct mx_proc_tree_node *ptn, int lvl) assert(ptn); struct mx_proc_tree_node *current; - - current = ptn; - long pagesize; pagesize = sysconf(_SC_PAGESIZE); From 3ce871a338f7ac38cc0e32d25d05d20b9e464a10 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 21 Feb 2022 10:40:51 +0100 Subject: [PATCH 14/30] tree: Apply cosmetics --- mx_flock.c | 1 - mx_log.h | 2 +- mx_util.c | 1 - mxq_daemon.c | 1 - mxq_group.c | 2 -- mxqadmin.c | 2 -- mxqd.c | 1 - mxqdump.c | 3 +-- mxqkill.c | 2 -- mxqps.c | 1 - test_mx_mysql.c | 1 - test_mx_util.c | 1 - test_mxqd_control.c | 1 - 13 files changed, 2 insertions(+), 17 deletions(-) diff --git a/mx_flock.c b/mx_flock.c index 5f90999b..db630c21 100644 --- a/mx_flock.c +++ b/mx_flock.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include diff --git a/mx_log.h b/mx_log.h index 096f5652..0518b17c 100644 --- a/mx_log.h +++ b/mx_log.h @@ -53,7 +53,7 @@ int mx_log_level_get(void); int mx_log_level_mxlog_to_syslog(int level); int mx_log_level_syslog_to_mxlog(int level); -int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 5, 6)));; +int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 5, 6))); int mx_log_printf(const char *fmt, ...); int mx_log_finish(void); diff --git a/mx_util.c b/mx_util.c index c1d5f314..52e890de 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include diff --git a/mxq_daemon.c b/mxq_daemon.c index 9fea495b..7ae01791 100644 --- a/mxq_daemon.c +++ b/mxq_daemon.c @@ -1,4 +1,3 @@ - #include #include diff --git a/mxq_group.c b/mxq_group.c index 3c849115..066eff38 100644 --- a/mxq_group.c +++ b/mxq_group.c @@ -1,4 +1,3 @@ - #include #include @@ -377,4 +376,3 @@ int mxq_load_running_groups_for_user(struct mx_mysql *mysql, struct mxq_group ** *mxq_groups = groups; return res; } - diff --git a/mxqadmin.c b/mxqadmin.c index 3702204f..713f209f 100644 --- a/mxqadmin.c +++ b/mxqadmin.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include @@ -400,4 +399,3 @@ int main(int argc, char *argv[]) mx_log_info("MySQL: Connection to database closed."); return 1; } - diff --git a/mxqd.c b/mxqd.c index 8918841e..6517f5f2 100644 --- a/mxqd.c +++ b/mxqd.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #define MXQ_TYPE_SERVER diff --git a/mxqdump.c b/mxqdump.c index dae30a57..0e69b066 100644 --- a/mxqdump.c +++ b/mxqdump.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include @@ -813,4 +812,4 @@ int main(int argc, char *argv[]) mx_mysql_finish(&mysql); mx_log_info("MySQL: Connection to database closed."); return 0; -}; +} diff --git a/mxqkill.c b/mxqkill.c index 65d1e96a..af4b602b 100644 --- a/mxqkill.c +++ b/mxqkill.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include @@ -507,4 +506,3 @@ int main(int argc, char *argv[]) mx_log_info("MySQL: Connection to database closed."); return 1; } - diff --git a/mxqps.c b/mxqps.c index 2e956a85..ee21424a 100644 --- a/mxqps.c +++ b/mxqps.c @@ -1,4 +1,3 @@ - #include #include #include diff --git a/test_mx_mysql.c b/test_mx_mysql.c index 19579953..3d1d0c9f 100644 --- a/test_mx_mysql.c +++ b/test_mx_mysql.c @@ -1,4 +1,3 @@ - #include #include diff --git a/test_mx_util.c b/test_mx_util.c index 6b3c3d7d..e55d0070 100644 --- a/test_mx_util.c +++ b/test_mx_util.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include diff --git a/test_mxqd_control.c b/test_mxqd_control.c index 3fd27c1b..c8ba25b3 100644 --- a/test_mxqd_control.c +++ b/test_mxqd_control.c @@ -1,4 +1,3 @@ - #define _GNU_SOURCE #include From 76b7022bca8a8394a6eaacd2626ccee319b5cc00 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 14:24:45 +0100 Subject: [PATCH 15/30] mx_flock: Don't call _flock_free to early Don't call _flock_free before flock->fname has been initialized. --- mx_flock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mx_flock.c b/mx_flock.c index db630c21..e3d88511 100644 --- a/mx_flock.c +++ b/mx_flock.c @@ -89,7 +89,7 @@ struct mx_flock *mx_flock(int operation, char *fmt, ...) if (res == -1) { mx_log_err("vasprintf(): %m"); - _flock_free(lock); + free(lock); return NULL; } From 4f8799197085fd55acdd7195b59a2855a84d7186 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 14:40:29 +0100 Subject: [PATCH 16/30] mxqd: Only process parsable fspool files --- mxqd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mxqd.c b/mxqd.c index 6517f5f2..47d47827 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2260,10 +2260,11 @@ static int fspool_scan(struct mxq_server *server) { for (i=0;ifinished_jobsdir,namelist[i]->d_name); - fspool_is_valid_name_parse(namelist[i]->d_name,&job_id); - res=fspool_process_file(server,filename,job_id); - if (res>0) { - slots_returned += res; + if (fspool_is_valid_name_parse(namelist[i]->d_name,&job_id)) { + res=fspool_process_file(server,filename,job_id); + if (res>0) { + slots_returned += res; + } } free(namelist[i]); free(filename); From 523b995f6f49a5e025afd76a1d33827fd2bfa20f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 17:06:17 +0100 Subject: [PATCH 17/30] mxqd: Remove capability to run as non-root This feature was once added to help in development. However since then, mxqd has learned a few more more things (like mounting TMPDIR) which can not be done without privileges and would require more special code. Even if we special-case everywhere, testing done as non-root wouldn't exercise code paths of the real thing. I don't really use that feature anymore. Does anyone? Moreover, nowadays there are other options (like user namespaces). Remove feature to simplify code. --- mxqd.c | 125 +++++++++++++++++++++++---------------------------------- 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/mxqd.c b/mxqd.c index 47d47827..e5d5dcda 100644 --- a/mxqd.c +++ b/mxqd.c @@ -57,8 +57,6 @@ #define MXQ_JOB_TMPDIR_MNTDIR "/dev/shm/mxqd/mnt/job" #define MXQ_JOB_TMPDIR_FS "/scratch/local2" -#define RUNNING_AS_ROOT (getuid() == 0) - static int global_sigint_cnt=0; static int global_sigterm_cnt=0; static int global_sigquit_cnt=0; @@ -721,23 +719,16 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) arg_logdir = MXQ_LOGDIR; if (access(arg_logdir, R_OK|W_OK|X_OK)) { - if (!RUNNING_AS_ROOT) - mx_log_warning("Running mxqd as non-root user."); mx_log_err("MAIN: can't write to '%s': %m", arg_logdir); return -EX_IOERR; } res = setup_cronolog("/usr/sbin/cronolog", arg_logdir, "mxqd_log", "%Y/mxqd_log-%Y-%m"); if (!res) { - if (!RUNNING_AS_ROOT) - mx_log_warning("Running mxqd as non-root user."); mx_log_err("MAIN: cronolog setup failed. exiting."); return -EX_IOERR; } } - if (!RUNNING_AS_ROOT) - mx_log_warning("Running mxqd as non-root user."); - res = mx_mysql_initialize(&(server->mysql)); assert(res == 0); @@ -783,11 +774,7 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) server->memory_limit_slot_hard = arg_memory_limit_slot_hard; if (!arg_memory_limit_slot_soft) { - if (RUNNING_AS_ROOT) { - arg_memory_limit_slot_soft = server->memory_avg_per_slot; - } else { - arg_memory_limit_slot_soft = server->memory_total; - } + arg_memory_limit_slot_soft = server->memory_avg_per_slot; } else if (arg_memory_limit_slot_soft > server->memory_limit_slot_hard) { arg_memory_limit_slot_soft = server->memory_limit_slot_hard; } else if (arg_memory_limit_slot_soft < server->memory_avg_per_slot) { @@ -981,30 +968,27 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job) group->user_name, group->user_uid, group->group_id, job->job_id); } - if(RUNNING_AS_ROOT) { - - res = initgroups(passwd->pw_name, group->user_gid); - if (res == -1) { - mx_log_err("job=%s(%d):%lu:%lu initgroups() failed: %m", - group->user_name, group->user_uid, group->group_id, job->job_id); - return 0; - } + res = initgroups(passwd->pw_name, group->user_gid); + if (res == -1) { + mx_log_err("job=%s(%d):%lu:%lu initgroups() failed: %m", + group->user_name, group->user_uid, group->group_id, job->job_id); + return 0; + } - res = setregid(group->user_gid, group->user_gid); - if (res == -1) { - mx_log_err("job=%s(%d):%lu:%lu setregid(%d, %d) failed: %m", - group->user_name, group->user_uid, group->group_id, job->job_id, - group->user_gid, group->user_gid); - return 0; - } + res = setregid(group->user_gid, group->user_gid); + if (res == -1) { + mx_log_err("job=%s(%d):%lu:%lu setregid(%d, %d) failed: %m", + group->user_name, group->user_uid, group->group_id, job->job_id, + group->user_gid, group->user_gid); + return 0; + } - res = setreuid(group->user_uid, group->user_uid); - if (res == -1) { - mx_log_err("job=%s(%d):%lu:%lu setreuid(%d, %d) failed: %m", - group->user_name, group->user_uid, group->group_id, job->job_id, - group->user_uid, group->user_uid); - return 0; - } + res = setreuid(group->user_uid, group->user_uid); + if (res == -1) { + mx_log_err("job=%s(%d):%lu:%lu setreuid(%d, %d) failed: %m", + group->user_name, group->user_uid, group->group_id, job->job_id, + group->user_uid, group->user_uid); + return 0; } res = chdir(job->job_workdir); @@ -1973,22 +1957,20 @@ static void rename_outfiles(struct mxq_server *server, struct mxq_group *group, mxq_job_set_tmpfilenames(group, job); - if(RUNNING_AS_ROOT) { - res=initgroups(group->user_name,group->user_gid); - if (res==-1) { - mx_log_err("initgroups(\"%s\",%d): %m",group->user_name,group->user_gid); - exit(-errno); - } - res=setegid(group->user_gid); - if (res==-1) { - mx_log_err("setedid(%d): %m",group->user_gid); - exit(-errno); - } - res=seteuid(group->user_uid); - if (res==-1) { - mx_log_err("seteuid(%d): %m",group->user_uid); - exit(-errno); - } + res=initgroups(group->user_name,group->user_gid); + if (res==-1) { + mx_log_err("initgroups(\"%s\",%d): %m",group->user_name,group->user_gid); + exit(-errno); + } + res=setegid(group->user_gid); + if (res==-1) { + mx_log_err("setedid(%d): %m",group->user_gid); + exit(-errno); + } + res=seteuid(group->user_uid); + if (res==-1) { + mx_log_err("seteuid(%d): %m",group->user_uid); + exit(-errno); } if (!mx_streq(job->job_stdout, "/dev/null")) { @@ -2015,24 +1997,22 @@ static void rename_outfiles(struct mxq_server *server, struct mxq_group *group, } } - if(RUNNING_AS_ROOT) { - uid_t uid=getuid(); - uid_t gid=getgid(); - res=seteuid(uid); - if (res==-1) { - mx_log_err("seteuid(%d): %m",uid); - exit(-errno); - } - res=setegid(gid); - if (res==-1) { - mx_log_err("setegid(%d): %m",gid); - exit(-errno); - } - res=setgroups(server->supgid_cnt,server->supgid); - if (res==-1) { - mx_log_err("setgroups(): %m"); - exit(-errno); - } + uid_t uid=getuid(); + uid_t gid=getgid(); + res=seteuid(uid); + if (res==-1) { + mx_log_err("seteuid(%d): %m",uid); + exit(-errno); + } + res=setegid(gid); + if (res==-1) { + mx_log_err("setegid(%d): %m",gid); + exit(-errno); + } + res=setgroups(server->supgid_cnt,server->supgid); + if (res==-1) { + mx_log_err("setgroups(): %m"); + exit(-errno); } } @@ -2507,10 +2487,7 @@ int load_running_groups(struct mxq_server *server) grps = NULL; - if (RUNNING_AS_ROOT) - grp_cnt = mxq_load_running_groups(server->mysql, &grps); - else - grp_cnt = mxq_load_running_groups_for_user(server->mysql, &grps, getuid()); + grp_cnt = mxq_load_running_groups(server->mysql, &grps); for (i=0, total=0; i < grp_cnt; i++) { group = &grps[i]; From 218e94a7651bcc65c959e271e19b72da6ac860a6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 17:23:45 +0100 Subject: [PATCH 18/30] mx_call_external: Change EPIPE to EPROTO If an external helper does something unexpected like exiting with a non-zero exit status or sending more data than mxqd wants to handle, mx_call_external sets errno to an error code. Currenty we use EPIPE ("Broken pipe"). Change this to EPROTO ("Protocol error"), which seems to be better fitting. We assume that the external helper, which shares its stderr with mxqd, has already sent some diagnostic to the logfile. --- mx_util.c | 4 ++-- test_mx_util.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mx_util.c b/mx_util.c index 52e890de..7f99daf2 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1360,7 +1360,7 @@ static char *mx_call_external_v(char *helper, char **argv) { goto err_close; } if (len == sizeof(buf)) { - err = EPIPE; + err = EPROTO; goto err_close; } @@ -1369,7 +1369,7 @@ static char *mx_call_external_v(char *helper, char **argv) { int wstatus; waitpid(pid, &wstatus, 0); if (wstatus != 0) { - err = EPIPE; + err = EPROTO; goto err_err; } buf[len] = '\0'; diff --git a/test_mx_util.c b/test_mx_util.c index e55d0070..028a9ebb 100644 --- a/test_mx_util.c +++ b/test_mx_util.c @@ -545,13 +545,13 @@ static void test_mx_call_external() { assert(errno == 999); line = mx_call_external("/usr/bin/false", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); line = mx_call_external("/usr/bin/cat", "/usr/bin/bash", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); line = mx_call_external("/usr/bin/yes", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); } From 1690ccb312686284ec5006aff9b3acc01b7a79b5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 10:08:43 +0100 Subject: [PATCH 19/30] Doxfile: Update for Doxygen 1.8.18 Use `doxygen -u` to upgrade `Doxyfile`. --- Doxyfile | 254 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 181 insertions(+), 73 deletions(-) diff --git a/Doxyfile b/Doxyfile index 088173b2..9519c7ad 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.10 +# Doxyfile 1.8.17 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -93,6 +93,14 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. @@ -179,6 +187,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -226,7 +244,12 @@ TAB_SIZE = 4 # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) ALIASES = @@ -264,17 +287,26 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is +# Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # @@ -285,7 +317,7 @@ EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -293,6 +325,15 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -318,7 +359,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -424,6 +465,12 @@ EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -478,8 +525,8 @@ HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -502,7 +549,7 @@ INTERNAL_DOCS = NO # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# (including Cygwin) ands Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -689,7 +736,7 @@ LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -734,11 +781,18 @@ WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = NO +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated @@ -770,7 +824,7 @@ INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of # possible encodings. # The default value is: UTF-8. @@ -787,8 +841,10 @@ INPUT_ENCODING = UTF-8 # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, -# *.vhdl, *.ucf, *.qsf, *.as and *.js. +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen +# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = @@ -874,6 +930,10 @@ IMAGE_PATH = # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. INPUT_FILTER = @@ -883,6 +943,10 @@ INPUT_FILTER = # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. FILTER_PATTERNS = @@ -935,7 +999,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -967,12 +1031,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1112,7 +1176,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1148,6 +1212,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1171,13 +1246,13 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# environment (see: https://developer.apple.com/xcode/), introduced with OSX +# 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1216,7 +1291,7 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output @@ -1292,7 +1367,7 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1300,7 +1375,7 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1309,7 +1384,7 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1317,7 +1392,7 @@ QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1325,7 +1400,7 @@ QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = @@ -1418,7 +1493,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1429,8 +1504,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1457,8 +1538,8 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -1500,7 +1581,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1519,7 +1600,7 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1532,7 +1613,7 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Xapian (see: https://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1584,21 +1665,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1719,12 +1814,28 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_BIB_STYLE = plain +# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: NO. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_TIMESTAMP = NO + +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1764,9 +1875,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1775,8 +1886,8 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = @@ -1862,6 +1973,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1894,9 +2012,9 @@ DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2063,12 +2181,6 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -2082,15 +2194,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2318,6 +2421,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. From 05aaacedf6352711ce3f751f01919e583b163d14 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 12:28:46 +0100 Subject: [PATCH 20/30] mxqd: Fix accidental doxygen comment --- mxqd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index e5d5dcda..d963e280 100644 --- a/mxqd.c +++ b/mxqd.c @@ -868,7 +868,7 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job) } } - /** prepare environment **/ + /* prepare environment */ res = clearenv(); if (res != 0) { From 80c1e09eca5642332b90cbe71b797750fda99689 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 18:57:48 +0100 Subject: [PATCH 21/30] tree: Remove some dead stores --- mx_mysql.c | 2 +- mx_util.c | 2 +- mxq_daemon.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mx_mysql.c b/mx_mysql.c index da1efebf..ac066671 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -1052,7 +1052,7 @@ int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt) r->bind[col].buffer = *(r->data[col].string_ptr); r->bind[col].buffer_length = r->data[col].length; - res = mx__mysql_stmt_fetch_column(stmt, col, 0); + mx__mysql_stmt_fetch_column(stmt, col, 0); r->data[col].length = 0; r->bind[col].buffer = NULL; diff --git a/mx_util.c b/mx_util.c index 7f99daf2..6c644366 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1184,7 +1184,7 @@ char *mx_strvec_join(char *sep,char **strvec) p = stpcpy(p, strvec[i]); p = stpcpy(p, sep); } - p = stpcpy(p, strvec[i]); + stpcpy(p, strvec[i]); return out; } diff --git a/mxq_daemon.c b/mxq_daemon.c index 7ae01791..d0236887 100644 --- a/mxq_daemon.c +++ b/mxq_daemon.c @@ -145,7 +145,7 @@ int mxq_daemon_register(struct mx_mysql *mysql, struct mxq_daemon *daemon) daemon->daemon_id = insert_id; - res = mx_mysql_statement_close(&stmt); + mx_mysql_statement_close(&stmt); return (int)num_rows; } From 2b08bbd6ccfaa4cfd400f8698b9831b5c1a1de52 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 19:14:39 +0100 Subject: [PATCH 22/30] mxqd: Fix uninitialized value in error message In the "reaper died" codepath, the exit status has not yet read when the error message is emitted. Move error message behind the wait4 call. --- mxqd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index d963e280..34abdc06 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2432,7 +2432,6 @@ int catchall(struct mxq_server *server) waitpid(siginfo.si_pid, &status, WNOHANG); continue; } - mx_log_err("reaper died. status=%d. Cleaning up job from catchall.",status); job_list_remove_self(jlist); /* reap child and save new state */ @@ -2449,6 +2448,7 @@ int catchall(struct mxq_server *server) } assert(pid == siginfo.si_pid); + mx_log_err("reaper died. status=%d. Cleaning up job from catchall.",status); gettimeofday(&now, NULL); From 049ef4dd68aef74c93676e76e2880b8c20c878f1 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 19:29:43 +0100 Subject: [PATCH 23/30] mxqd: Fix use after free Capture jlist->next because jlist might be freed by job_is_lost() inside the loop body. --- mxqd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index 34abdc06..45efaab4 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2282,12 +2282,14 @@ static int lost_scan_one(struct mxq_server *server) struct mxq_user_list *ulist; struct mxq_group_list *glist; struct mxq_job_list *jlist; + struct mxq_job_list *next_job = NULL; struct mxq_job *job; for (ulist = server->users; ulist; ulist = ulist->next) { for (glist = ulist->groups; glist; glist = glist->next) { - for (jlist = glist->jobs; jlist; jlist = jlist->next) { + for (jlist = glist->jobs; jlist; jlist = next_job) { + next_job = jlist->next; job = &jlist->job; if (job->job_status == MXQ_JOB_STATUS_LOADED) { From ef54844c53c6d866ea8934a81e94f01f40443d89 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 19 Feb 2022 20:01:47 +0100 Subject: [PATCH 24/30] tree: Replace perror() with mx_log_err("... %m") --- mx_util.c | 4 ++-- mxqd.c | 14 +++++++------- ppidcache.c | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mx_util.c b/mx_util.c index 6c644366..e8eef56e 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1310,7 +1310,7 @@ time_t mx_clock_boottime() { struct timespec ts; int res = clock_gettime(CLOCK_BOOTTIME, &ts); if (res != 0) { - perror("clock_gettime"); + mx_log_err("clock_gettime: %m"); } return (ts.tv_sec); } @@ -1350,7 +1350,7 @@ static char *mx_call_external_v(char *helper, char **argv) { close(pipefd[0]); dup2(pipefd[1], 1); execv(helper, argv); - perror(helper); + mx_log_err("%s: %m", helper); exit(1); } close(pipefd[1]); diff --git a/mxqd.c b/mxqd.c index 45efaab4..d8d1dac7 100644 --- a/mxqd.c +++ b/mxqd.c @@ -327,7 +327,7 @@ static int cpuset_init(struct mxq_server *server) static void read_hostconfig_retry(struct keywordset *kws) { char *line = mx_call_external("/usr/sbin/hostconfig", NULL); if (!line) { - perror("hostconfig"); + mx_log_err("hostconfig: %m"); exit(1); } keywordset_add(kws, line); @@ -339,7 +339,7 @@ static char gpu_setup_script[] = LIBEXECDIR "/mxq/gpu-setup"; static int get_gpus() { char *line = mx_call_external(gpu_setup_script, "init", NULL); if (!line) { - perror("gpu-setup init"); + mx_log_err("gpu-setup init: %m"); exit(1); } int gpus = atoi(line); @@ -356,13 +356,13 @@ static void read_cpufeatures(struct keywordset *kws) { size_t linebuflen = 0; FILE *proc_cpuinfo = fopen("/proc/cpuinfo","r"); if (proc_cpuinfo == NULL) { - perror("/proc/cpuinfo"); + mx_log_err("/proc/cpuinfo: %m"); exit(1); } while (1) { ssize_t len = getline(&line, &linebuflen, proc_cpuinfo); if (len<0) { - perror("/proc/cpuinfo"); + mx_log_err("/proc/cpuinfo: %m"); exit(1); } if(line[len-1] == '\n') @@ -371,7 +371,7 @@ static void read_cpufeatures(struct keywordset *kws) { int i=sscanf(line,"flags : %n", &keywords); if (i==EOF) { if (ferror(proc_cpuinfo)) { - perror("/proc/cpuinfo"); + mx_log_err("/proc/cpuinfo: %m"); exit(1); } fprintf(stderr,"%s: unexpected EOF during read\n","proc/cpuinfo"); @@ -910,7 +910,7 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job) mx_asprintf_forever(&uid, "%u", group->user_uid); char *gpu_uuid = mx_call_external(gpu_setup_script, "job-init", pid, uid, NULL); if (!gpu_uuid) { - perror("gpu-setup job-init"); + mx_log_err("gpu-setup job-init: %m"); exit(1); } mx_setenv_forever("CUDA_VISIBLE_DEVICES", gpu_uuid); @@ -2050,7 +2050,7 @@ static void release_gpu(struct mxq_server *server, struct mxq_group *group, stru char *gpu_uuid = mx_call_external(gpu_setup_script, "job-release", pid, NULL); free(pid); if (!gpu_uuid) { - perror("gpu-setup job-release"); + mx_log_err("gpu-setup job-release: %m"); exit(1); } free(gpu_uuid); diff --git a/ppidcache.c b/ppidcache.c index 9d07de43..11d95204 100644 --- a/ppidcache.c +++ b/ppidcache.c @@ -3,6 +3,7 @@ #include "mx_util.h" #include "ppidcache.h" #include "mx_proc.h" +#include "mx_log.h" struct entry { pid_t pid; @@ -79,7 +80,7 @@ void ppidcache_scan(struct ppidcache *ppidcache) { ppidcache->count = 0; dir = opendir("/proc"); if (dir == NULL) { - perror("/proc"); + mx_log_err("/proc: %m"); return; } while (1) { @@ -87,7 +88,7 @@ void ppidcache_scan(struct ppidcache *ppidcache) { dirent = readdir(dir); if (dirent == NULL) { if (errno) - perror("/proc"); + mx_log_err("/proc: %m"); return; } if (strspn(dirent->d_name, "0123456789") != strlen(dirent->d_name)) From addc9979758577f7caec946face8766f33852fdc Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 09:32:57 +0100 Subject: [PATCH 25/30] mxqd: Remove unused variable --- mxqd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mxqd.c b/mxqd.c index d8d1dac7..cbbdff84 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2727,7 +2727,6 @@ int main(int argc, char *argv[]) static struct timespec poll_interval={20,0}; /* 20 seconds */ siginfo_t siginfo; - int saved_argc; _mx_cleanup_free_ char *saved_argv_str = NULL; _mx_cleanup_free_ char *saved_cwd = NULL; @@ -2743,7 +2742,6 @@ int main(int argc, char *argv[]) /*** server init ***/ - saved_argc = argc; saved_argv_str = mx_strvec_to_str(argv); saved_cwd = get_current_dir_name(); @@ -2883,7 +2881,6 @@ int main(int argc, char *argv[]) while (global_sigrestart_cnt) { char **saved_argv; - saved_argc = argc; saved_argv_str = mx_strvec_to_str(argv); saved_cwd = get_current_dir_name(); From e4020668b050eb51a5fae49bc8e90eb659e4f805 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 09:34:57 +0100 Subject: [PATCH 26/30] mxqd: Remove dead stores --- mxqd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mxqd.c b/mxqd.c index cbbdff84..0bc629e1 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2742,9 +2742,6 @@ int main(int argc, char *argv[]) /*** server init ***/ - saved_argv_str = mx_strvec_to_str(argv); - saved_cwd = get_current_dir_name(); - mx_log_level_set(MX_LOG_INFO); res = server_init(server, argc, argv); From 0de4433162f55b9791b83fb8f50a0b362fe08d9f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 09:37:09 +0100 Subject: [PATCH 27/30] mxqd: Move variables into block scope --- mxqd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mxqd.c b/mxqd.c index 0bc629e1..9c672ae3 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2727,9 +2727,6 @@ int main(int argc, char *argv[]) static struct timespec poll_interval={20,0}; /* 20 seconds */ siginfo_t siginfo; - _mx_cleanup_free_ char *saved_argv_str = NULL; - _mx_cleanup_free_ char *saved_cwd = NULL; - sigfillset(&all_signals); sigemptyset(&sigset); @@ -2877,6 +2874,8 @@ int main(int argc, char *argv[]) server_close(server); while (global_sigrestart_cnt) { + _mx_cleanup_free_ char *saved_argv_str = NULL; + _mx_cleanup_free_ char *saved_cwd = NULL; char **saved_argv; saved_argv_str = mx_strvec_to_str(argv); saved_cwd = get_current_dir_name(); From 3f2fe0080032ff973a6dc34887b2be925b3ad92b Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 09:47:21 +0100 Subject: [PATCH 28/30] mxqd: Remove unnecessary cd(pwd) --- mxqd.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mxqd.c b/mxqd.c index 9c672ae3..9b725f35 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2875,19 +2875,12 @@ int main(int argc, char *argv[]) while (global_sigrestart_cnt) { _mx_cleanup_free_ char *saved_argv_str = NULL; - _mx_cleanup_free_ char *saved_cwd = NULL; char **saved_argv; + saved_argv_str = mx_strvec_to_str(argv); - saved_cwd = get_current_dir_name(); mx_log_info("Reexecuting mxqd... "); - res = chdir(saved_cwd); - if (res < 0) { - mx_log_fatal("Aborting restart: chdir(%s) failed: %m", saved_cwd); - break; - } - saved_argv = mx_strvec_from_str(saved_argv_str); if (!saved_argv) { mx_log_fatal("Can't recaculate commandline. str_to_strvev(%s) failed: %m", saved_argv_str); From c45a22e6d6749d3ede2c9498f099e236c182f1bb Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 15:35:27 +0100 Subject: [PATCH 29/30] mxqd: Simplify reexec Currently argv is converted to a string and back to an array before mxqd reexecs itself. Use the original argv instead. Difference is, that options are not included in the informational messages. --- mxqd.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/mxqd.c b/mxqd.c index 9b725f35..21ee9b80 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2874,27 +2874,12 @@ int main(int argc, char *argv[]) server_close(server); while (global_sigrestart_cnt) { - _mx_cleanup_free_ char *saved_argv_str = NULL; - char **saved_argv; - - saved_argv_str = mx_strvec_to_str(argv); - - mx_log_info("Reexecuting mxqd... "); - - saved_argv = mx_strvec_from_str(saved_argv_str); - if (!saved_argv) { - mx_log_fatal("Can't recaculate commandline. str_to_strvev(%s) failed: %m", saved_argv_str); - break; - } - mx_log_info("-------------------------------------------------------------"); - mx_log_info(" Reexecuting %s", saved_argv_str); + mx_log_info(" Reexecuting %s", argv[0]); mx_log_info("-------------------------------------------------------------"); - - res = execvp(saved_argv[0], saved_argv); - mx_log_fatal("execvp(\"%s\", ...): %m", saved_argv[0]); + res = execvp(argv[0], argv); + mx_log_fatal("execvp(\"%s\", ...): %m", argv[0]); break; - } mx_log_info("cu, mx."); From 06562ea1c981aa827b5388997342c9fd0410224f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Feb 2022 15:50:41 +0100 Subject: [PATCH 30/30] mxqd: Remove pointless loop --- mxqd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mxqd.c b/mxqd.c index 21ee9b80..a3ba9adf 100644 --- a/mxqd.c +++ b/mxqd.c @@ -2873,13 +2873,12 @@ int main(int argc, char *argv[]) server_close(server); - while (global_sigrestart_cnt) { + if (global_sigrestart_cnt) { mx_log_info("-------------------------------------------------------------"); mx_log_info(" Reexecuting %s", argv[0]); mx_log_info("-------------------------------------------------------------"); res = execvp(argv[0], argv); mx_log_fatal("execvp(\"%s\", ...): %m", argv[0]); - break; } mx_log_info("cu, mx.");