Mercurial > sci
diff sciworkerd/sciworkerd.c @ 75:72d998f01b4b
sciworkerd: cool down CPU usage
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 30 Jan 2023 08:42:40 +0100 |
parents | 95bc6b4ec753 |
children | 71cd8447e3a4 |
line wrap: on
line diff
--- a/sciworkerd/sciworkerd.c Tue Jan 24 11:30:32 2023 +0100 +++ b/sciworkerd/sciworkerd.c Mon Jan 30 08:42:40 2023 +0100 @@ -22,6 +22,7 @@ #include <stdint.h> #include <string.h> #include <time.h> +#include <unistd.h> #include <utlist.h> @@ -234,9 +235,13 @@ pid_t pid; int ret; - /* First, read every pipes. */ - if (!(fdsz = count(tasks))) + /* + * Count every pipes. If there is no job we can just wait a little bit. + */ + if (!(fdsz = count(tasks))) { + sleep(1); return; + } fds = util_calloc(fdsz, sizeof (*fds));