]> granicus.if.org Git - fcron/commitdiff
@-line can now be run every second
authorThibault Godouet <fcron@free.fr>
Wed, 10 Jun 2015 21:18:34 +0000 (22:18 +0100)
committerThibault Godouet <fcron@free.fr>
Wed, 10 Jun 2015 21:18:34 +0000 (22:18 +0100)
conf.c
configure.in
doc/en/changes.sgml
fileconf.c
job.c

diff --git a/conf.c b/conf.c
index 1ac0ba832b5bdd4fc1e1e50804bdf0de19430580..06e11cae2129eaa1b592f63a3e9ade63789ced36 100644 (file)
--- 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;
index b929e203601db6453074da6d5c2af9b79a2afb98..ff4ee91471f8e5e0c5bb01ed7408a208a1358b89 100644 (file)
@@ -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"
     ;;
index d8d43ce20ddd024e5408fcfaa72b949a62227675..99ca00430111017befd506293251e2c9af436514 100644 (file)
@@ -14,6 +14,9 @@ A copy of the license is included in gfdl.sgml.
 
       <itemizedlist>
         <title>From version 3.2.0 to 3.2.1</title>
+           <listitem>
+             <para>@-line can now be run every second (minimum every 10s previously)</para>
+           </listitem>
            <listitem>
              <para>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.</para>
index 49a1c8017915d18d9cb3ea0171501c42eab5eaad..1f452a640f14a47b1e891f1a7eff8939c5daea39 100644 (file)
@@ -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 c0f271ee6c1fe1d11644b0ebcae590524c865073..26c0f29d1922ebaf30ea36a4775adf68b23b22bc 100644 (file)
--- 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 */
 
     }