From cb31fae5d538cdc3a623f8c1b42e3ee137e5bace Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 22 Oct 2015 21:43:53 +0200 Subject: [PATCH 1/3] README.md: Add links to sources --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 2c895b3..fb37fe7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ # mxq MXQ - mariux64 job scheduling system +## Sources +### Main git repository + +https://github.molgen.mpg.de/mariux64/mxq + +### github.com clone + +https://github.com/mariux/mxq + ## Installation ### Install using `GNU make` ``` From 259145a930d7e9a193e12433a89fd017e945f957 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 22 Oct 2015 22:35:52 +0200 Subject: [PATCH 2/3] mx_util: Add mx_within_rate_limit_or_return(sec, ret) --- mx_util.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mx_util.h b/mx_util.h index aeb2489..f2adb2f 100644 --- a/mx_util.h +++ b/mx_util.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "mx_log.h" @@ -118,6 +120,18 @@ static inline void __mx_fclose(FILE **ptr) { #undef mx_streq_nocase #define mx_streq_nocase(a, b) (strcasecmp((a), (b)) == 0) +#define mx_within_rate_limit_or_return(sec, ret) \ + do {\ + static struct timeval _sleep = {0};\ + struct timeval _now;\ + struct timeval _delta;\ + gettimeofday(&_now, NULL);\ + timersub(&_now, &_sleep, &_delta);\ + if (_delta.tv_sec < (sec))\ + return (ret);\ + _sleep = _now;\ + } while(0) + int mx_strbeginswith(char *str, const char *start, char **endptr); int mx_stribeginswith(char *str, const char *start, char **endptr); int mx_strbeginswithany(char *str, char **starts, char **endptr); From fa41df3f110ed028891ec4308308c906bb321ea5 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 22 Oct 2015 22:37:14 +0200 Subject: [PATCH 3/3] mxqd: Limit call rate of killall_over_time() to max. every 5 minutes --- mxqd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index 48b5e9b..047b6ed 100644 --- a/mxqd.c +++ b/mxqd.c @@ -1509,6 +1509,11 @@ int killall_over_time(struct mxq_server *server) assert(server); + /* limit killing to every >= 5 minutes */ + mx_within_rate_limit_or_return(5*60, 1); + + mx_log_info("killall_over_time: Sending signals to all jobs running longer than requested."); + gettimeofday(&now, NULL); for (user=server->users; user; user=user->next) { @@ -1906,7 +1911,6 @@ int main(int argc, char *argv[]) killallcancelled(&server, SIGTERM, 0); killallcancelled(&server, SIGINT, 0); killall_over_time(&server); - killall_over_time(&server); mx_log_info("jobs_running=%lu global_sigint_cnt=%d global_sigterm_cnt=%d : Exiting. Wating for jobs to finish. Sleeping for a while.", server.jobs_running, global_sigint_cnt, global_sigterm_cnt);