Merge branch 'refs/heads/t/max-errors'
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 25 Feb 2015 12:23:56 +0000 (13:23 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 25 Feb 2015 12:24:22 +0000 (13:24 +0100)
The topic branch was cooking for about a week, and it was tested with
no problems on several multi-terabyte file systems.

* Rework restart logic, introduce --max-errors.
* Fix typo in help text of --daemon.

Makefile
NEWS
dss.c
exec.c
file.c
snap.c
str.c
tv.c
tv.h

index dc57f3d07d640ffcaf578c317519318f00800a48..7a4b6a98c9c5b3af9efdbfa5f2bf6040e0b7e3f5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -53,5 +53,5 @@ index.html: dss.1.html index.html.in INSTALL README NEWS
        sed -e '1,/@NEWS@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
        grutatxt -nb < INSTALL >> $@
        sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
-       sed -e '1,/Return to Main Contents/d' -e '/Index/,$$d' dss.1.html >> $@
+       sed -e '1,/Return to Main Contents/d' -e '/SEE ALSO/,$$d' dss.1.html >> $@
        sed -e '1,/@MAN_PAGE@/d' index.html.in >> $@
diff --git a/NEWS b/NEWS
index db77b4591b3775b458bb8b86a0a882cae5b4d432..444c12eef89103900bf3aaa14fcb6bfe747d4d86 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,8 +2,13 @@
 0.1.6 (to be announced)
 -----------------------
 
-- New option --min-complete
-- New home page URL, email address
+ - New option --min-complete to specify the minimal number of snapshots
+   to keep.
+
+ - Improved handling of rsync errors. The new --max-rsync-errors option
+ tells dss to terminate after the given number of rsync failures.
+
+ - New home page URL, email address
 
 ------------------
 0.1.5 (2014-01-14)
diff --git a/dss.c b/dss.c
index 95c4c03ab1c3467aa33507b35f7e57cc81d4aea9..07a60425170ddab063ee6071d4901993a9db8c62 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1524,6 +1524,7 @@ int main(int argc, char **argv)
        if (ret < 0)
                goto out;
        ret = call_command_handler();
+       signal_shutdown();
 out:
        if (ret < 0)
                DSS_EMERG_LOG(("%s\n", dss_strerror(-ret)));
diff --git a/exec.c b/exec.c
index c08ef392dc064aac09d7f2aa57ba3f295551ef83..920ea0e2e9086bee1b5d82e72a8f051ad32efd3a 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -50,7 +50,7 @@ void dss_exec(pid_t *pid, const char *file, char *const *const args)
  * Exec the command given as a command line.
  *
  * \param pid Will hold the pid of the created process upon return.
- * \param cmdline Holds the command and its arguments, seperated by spaces.
+ * \param cmdline Holds the command and its arguments, separated by spaces.
  *
  * This function uses fork/exec to create a new process.
  *
diff --git a/file.c b/file.c
index ef7cd528680ee03c021e8cbe2bc1ab6a2434084c..84944082960055e272e942aa40a760b5709eb875 100644 (file)
--- a/file.c
+++ b/file.c
@@ -23,7 +23,7 @@
  * Call a function for each subdirectory of the current working directory.
  *
  * \param dirname The directory to traverse.
- * \param func The function to call for each subdirecrtory.
+ * \param func The function to call for each subdirectory.
  * \param private_data Pointer to an arbitrary data structure.
  *
  * For each top-level directory under \a dirname, the supplied function \a func is
diff --git a/snap.c b/snap.c
index 7c16d2e870b8e4e918a1486ab801bf31f1344c47..2ec195653c8ce65091b31f512010326649387bf1 100644 (file)
--- a/snap.c
+++ b/snap.c
@@ -84,7 +84,7 @@ static int is_snapshot(const char *dirname, int64_t now, int unit_interval,
        }
        if (!strcmp(dash + 1, "incomplete.being_deleted")) {
                s->completion_time = -1;
-               s->flags = SS_BEING_DELETED; /* mot cpmplete, being deleted */
+               s->flags = SS_BEING_DELETED; /* not complete, being deleted */
                goto success;
        }
        tmp = dash + 1;
diff --git a/str.c b/str.c
index d6c768d0bc90e3a0873f1aca8312512c9195bd91..cca898d6aa0e4fdcf05eaea528b7d223ef054ccf 100644 (file)
--- a/str.c
+++ b/str.c
 #include "err.h"
 #include "str.h"
 
-/**
- * Write a message to a dynamically allocated string.
- *
- * \param fmt Usual format string.
- * \param p Result pointer.
- *
- * \sa printf(3). */
-#define VSPRINTF(fmt, p) \
-{ \
-       int n; \
-       size_t size = 100; \
-       p = dss_malloc(size); \
-       while (1) { \
-               va_list ap; \
-               /* Try to print in the allocated space. */ \
-               va_start(ap, fmt); \
-               n = vsnprintf(p, size, fmt, ap); \
-               va_end(ap); \
-               /* If that worked, return the string. */ \
-               if (n > -1 && n < size) \
-                       break; \
-               /* Else try again with more space. */ \
-               if (n > -1) /* glibc 2.1 */ \
-                       size = n + 1; /* precisely what is needed */ \
-               else /* glibc 2.0 */ \
-                       size *= 2; /* twice the old size */ \
-               p = dss_realloc(p, size); \
-       } \
-}
-
 /**
  * dss' version of realloc().
  *
@@ -165,15 +135,30 @@ __must_check __malloc char *dss_strdup(const char *s)
 __must_check __printf_1_2 __malloc char *make_message(const char *fmt, ...)
 {
        char *msg;
+       size_t size = 100;
+
+       msg = dss_malloc(size);
+       while (1) {
+               int n;
+               va_list ap;
 
-       VSPRINTF(fmt, msg);
-       return msg;
+               /* Try to print in the allocated space. */
+               va_start(ap, fmt);
+               n = vsnprintf(msg, size, fmt, ap);
+               va_end(ap);
+               /* If that worked, return the string. */
+               if (n < size)
+                       return msg;
+               /* Else try again with more space. */
+               size = n + 1; /* precisely what is needed */
+               msg = dss_realloc(msg, size);
+       }
 }
 
 /**
  * Get the home directory of the current user.
  *
- * \return A dynammically allocated string that must be freed by the caller. If
+ * \return A dynamically allocated string that must be freed by the caller. If
  * the home directory could not be found, this function returns "/tmp".
  */
 __must_check __malloc char *get_homedir(void)
@@ -214,7 +199,7 @@ int dss_atoi64(const char *str, int64_t *value)
 /**
  * Get the logname of the current user.
  *
- * \return A dynammically allocated string that must be freed by the caller. On
+ * \return A dynamically allocated string that must be freed by the caller. On
  * errors, the string "unknown user" is returned, i.e. this function never
  * returns \p NULL.
  *
@@ -233,7 +218,7 @@ __must_check __malloc char *dss_logname(void)
  * \param argv_ptr Pointer to the list of substrings.
  * \param delim Delimiter.
  *
- * This function modifies \a args by replacing each occurance of \a delim by
+ * This function modifies \a args by replacing each occurrence of \a delim by
  * zero. A \p NULL-terminated array of pointers to char* is allocated dynamically
  * and these pointers are initialized to point to the broken-up substrings
  * within \a args. A pointer to this array is returned via \a argv_ptr.
@@ -242,7 +227,7 @@ __must_check __malloc char *dss_logname(void)
  */
 unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
 {
-       char *p = args;
+       char *p;
        char **argv;
        size_t n = 0, i, j;
 
diff --git a/tv.c b/tv.c
index 5beca9d0d36ab83f06e22f55b0d8a920270e994a..8ab5e5a90a6bd151c87750adb761c135b7ec774e 100644 (file)
--- a/tv.c
+++ b/tv.c
 #include "log.h"
 #include "time.h"
 
-/**
- * Convert struct timeval to milliseconds.
- *
- * \param tv The time value value to convert.
- *
- * \return The number off milliseconds in \a tv.
- */
-long unsigned tv2ms(const struct timeval *tv)
-{
-       return tv->tv_sec * 1000 + (tv->tv_usec + 500)/ 1000;
-}
-
-/**
- * Convert milliseconds to a struct timeval.
- *
- * \param n The number of milliseconds.
- * \param tv Result pointer.
- */
-void ms2tv(long unsigned n, struct timeval *tv)
-{
-       tv->tv_sec = n / 1000;
-       tv->tv_usec = (n % 1000) * 1000;
-}
-
-/**
- * Convert a double to a struct timeval.
- *
- * \param x The value to convert.
- * \param tv Result pointer.
- */
-void d2tv(double x, struct timeval *tv)
-{
-       tv->tv_sec = x;
-       tv->tv_usec = (x - (double)tv->tv_sec) * 1000.0 * 1000.0 + 0.5;
-}
-
 /**
  * Compute the difference of two time values.
  *
@@ -86,56 +50,6 @@ int tv_diff(const struct timeval *b, const struct timeval *a, struct timeval *di
        return ret;
 }
 
-/**
- * Add two time values.
- *
- * \param a First addend.
- * \param b Second addend.
- * \param sum Contains the sum \a + \a b on return.
- */
-void tv_add(const struct timeval *a, const struct timeval *b,
-       struct timeval *sum)
-{
-       sum->tv_sec = a->tv_sec + b->tv_sec;
-       if (a->tv_usec + b->tv_usec >= 1000 * 1000) {
-               sum->tv_sec++;
-               sum->tv_usec = a->tv_usec + b->tv_usec - 1000 * 1000;
-       } else
-               sum->tv_usec = a->tv_usec + b->tv_usec;
-}
-
-/**
- * Compute integer multiple of given struct timeval.
- *
- * \param mult The integer value to multiply with.
- * \param tv The timevalue to multiply.
- *
- * \param result Contains \a mult * \a tv on return.
- */
-void tv_scale(const unsigned long mult, const struct timeval *tv,
-       struct timeval *result)
-{
-       result->tv_sec = mult * tv->tv_sec;
-       result->tv_sec += tv->tv_usec * mult / 1000 / 1000;
-       result->tv_usec = tv->tv_usec * mult % (1000 * 1000);
-}
-
-/**
- * Compute a fraction of given struct timeval.
- *
- * \param divisor The integer value to divide by.
- * \param tv The timevalue to divide.
- * \param result Contains (1 / mult) * tv on return.
- */
-void tv_divide(const unsigned long divisor, const struct timeval *tv,
-       struct timeval *result)
-{
-       uint64_t x = ((uint64_t)tv->tv_sec * 1000 * 1000 + tv->tv_usec) / divisor;
-
-       result->tv_sec = x / 1000 / 1000;
-       result->tv_usec = x % (1000 * 1000);
-}
-
 int64_t get_current_time(void)
 {
        time_t now;
diff --git a/tv.h b/tv.h
index f2021e0834591de533598fe486639cbfa95a4b81..c61a848a81aa568aa54a9546c2ebf515623ab58b 100644 (file)
--- a/tv.h
+++ b/tv.h
@@ -1,9 +1,2 @@
 int tv_diff(const struct timeval *b, const struct timeval *a, struct timeval *diff);
-long unsigned tv2ms(const struct timeval*);
-void d2tv(double, struct timeval*);
-void tv_add(const struct timeval*, const struct timeval *, struct timeval *);
-void tv_scale(const unsigned long, const struct timeval *, struct timeval *);
-void tv_divide(const unsigned long divisor, const struct timeval *tv,
-       struct timeval *result);
-void ms2tv(const long unsigned n, struct timeval *tv);
 int64_t get_current_time(void);