From 111a894f8ec2695aa810012c1cd67c0e95975171 Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Wed, 10 Jun 2015 22:18:34 +0100 Subject: [PATCH] @-line can now be run every second --- conf.c | 2 +- configure.in | 2 +- doc/en/changes.sgml | 3 +++ fileconf.c | 2 +- job.c | 66 +++++++++++++++++++++------------------------ 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/conf.c b/conf.c index 1ac0ba8..06e11ca 100644 --- a/conf.c +++ b/conf.c @@ -957,7 +957,7 @@ add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str, } } else { /* is_td(cl->cl_option) */ - if (cl->cl_timefreq < 10) { + if (cl->cl_timefreq < 1) { error("Invalid timefreq %ld for job '%s': setting to 1 day", cl->cl_timefreq, cl->cl_shell); cl->cl_timefreq = 3600 * 24; diff --git a/configure.in b/configure.in index b929e20..ff4ee91 100644 --- a/configure.in +++ b/configure.in @@ -711,7 +711,7 @@ AC_ARG_WITH(debug, debug="0" ;; yes) - cflags="-DDEBUG -g -Wall -DFOREGROUND -DMALLOC_CHECK_=2 -Wpointer-arith -Wstrict-prototypes" + cflags="-DDEBUG -DCHECKRUNJOB -g -Wall -DFOREGROUND -DMALLOC_CHECK_=2 -Wpointer-arith -Wstrict-prototypes" bootinstall=0 debug="1" ;; diff --git a/doc/en/changes.sgml b/doc/en/changes.sgml index d8d43ce..99ca004 100644 --- a/doc/en/changes.sgml +++ b/doc/en/changes.sgml @@ -14,6 +14,9 @@ A copy of the license is included in gfdl.sgml. From version 3.2.0 to 3.2.1 + + @-line can now be run every second (minimum every 10s previously) + add From: header to emails. Similarly to other crons, use: "From: %s (fcron)" with %s being either the user the job is run as or the value of MAILFROM. diff --git a/fileconf.c b/fileconf.c index 49a1c80..1f452a6 100644 --- a/fileconf.c +++ b/fileconf.c @@ -1483,7 +1483,7 @@ read_freq(char *ptr, cf_t * cf) fprintf(stderr, "%s:%d: Error while reading frequency %s: skipping line.\n", file_name, line, - (cl->cl_timefreq < 10) ? "(lower than 10s) " : ""); + (cl->cl_timefreq < 1) ? "(lower than 1s) " : ""); goto exiterr; } diff --git a/job.c b/job.c index c0f271e..26c0f29 100644 --- a/job.c +++ b/job.c @@ -397,41 +397,48 @@ read_write_pipe(int fd, void *buf, size_t size, int action) while (size_processed < size) { errno = 0; - if (action == PIPE_READ) + if (action == PIPE_READ) { ret = read(fd, (char *)buf + size_processed, size); - else if (action == PIPE_WRITE) + } + else if (action == PIPE_WRITE) { ret = write(fd, (char *)buf + size_processed, size); + } else { error("Invalid action parameter for function read_write_pipe():" " %d", action); return ERR; } - if (ret > 0) + if (ret > 0) { /* some data read correctly -- we still may need * one or several calls of read() to read the rest */ size_processed += ret; - else if (ret < 0 && errno == EINTR) + } + else if (ret < 0 && errno == EINTR) { /* interrupted by a signal : let's try again */ continue; - else { - /* error */ - - if (ret == 0) { - /* is it really an error when writing ? should we continue - * in this case ? */ - if (num_retry < 3) { - num_retry++; - error_e - ("read_write_pipe(): read/write returned 0: retrying... (size: %d, size_processed: %d, num_retry: %d)", - size, size_processed, num_retry); - sleep(1); - continue; - } - else - return ERR; + } + else if (ret == 0) { + /* Notes: + * - is it really an error when writing ? should we simply 'continue' + * in this case ? + * - read() on a pipe returning 0 means the pipe was closed at the other end. + * We shouldn't need to retry multiple times (but it should never happen) */ + if (num_retry < 3) { + num_retry++; + error_e + ("read_write_pipe(): read/write returned 0: retrying... " + "(size: %d, size_processed: %d, num_retry: %d)", + size, size_processed, num_retry); + sleep(1); + continue; } - else - return errno; + else { + return ERR; + } + } + else { + /* in particular this includes write() returning -1 with errno=EPIPE */ + return errno; } } @@ -698,17 +705,6 @@ run_job(struct exe_t *exeent) xfclose_check(&pipef, "child's pipef"); } - /* FIXME : FOLLOWING HACK USELESS ? */ - /* FIXME : HACK - * this is a try to fix the bug on sorcerer linux (no jobs - * exectued at all, and - * "Could not read job pid : setting it to -1: No child processes" - * error messages) */ - /* use a select() or similar to know when parent has read - * the pid (with a timeout !) */ - /* // */ - sleep(2); - /* // */ #ifdef CHECKRUNJOB debug("run_job(): child: closing pipe with parent"); #endif /* CHECKRUNJOB */ @@ -739,7 +735,7 @@ run_job(struct exe_t *exeent) exeent->e_ctrl_pid = pid; #ifdef CHECKRUNJOB - debug("run_job(): about to read grand-child pid..."); + debug("run_job(): parent: about to read grand-child pid..."); #endif /* CHECKRUNJOB */ /* read the pid of the job */ @@ -760,7 +756,7 @@ run_job(struct exe_t *exeent) #ifdef CHECKRUNJOB debug - ("run_job(): finished reading pid of the job -- end of run_job()."); + ("run_job(): parent: finished reading pid of the job -- end of run_job()."); #endif /* CHECKRUNJOB */ } -- 2.47.3