Mercurial > sci
changeset 75:72d998f01b4b
sciworkerd: cool down CPU usage
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 30 Jan 2023 08:42:40 +0100 |
parents | 38bdcfb3d4f7 |
children | de0b36eabece |
files | sciworkerd/sciworkerd.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
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));