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` ``` diff --git a/mx_util.h b/mx_util.h index 16a27d3..508476c 100644 --- a/mx_util.h +++ b/mx_util.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "mx_log.h" @@ -71,6 +73,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); diff --git a/mxqd.c b/mxqd.c index 77706c7..09b8c5b 100644 --- a/mxqd.c +++ b/mxqd.c @@ -1512,6 +1512,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) { @@ -1909,7 +1914,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);