adds dav-sync lock timeout config element

Sun, 24 Sep 2017 11:31:01 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 Sep 2017 11:31:01 +0200
changeset 316
9d0505d80044
parent 315
7db4dbf4e6f9
child 317
7eea57f6d847

adds dav-sync lock timeout config element

dav/main.c file | annotate | diff | comparison | revisions
dav/scfg.c file | annotate | diff | comparison | revisions
dav/scfg.h file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sat Sep 23 11:45:03 2017 +0200
+++ b/dav/main.c	Sun Sep 24 11:31:01 2017 +0200
@@ -1326,7 +1326,7 @@
     time_t timeout = 0;
     char *timeoutstr = cmd_getoption(a, "timeout");
     if(timeoutstr) {
-        if(!sstrcasecmp(sstr(timeoutstr), S("infinity"))) {
+        if(!sstrcasecmp(sstr(timeoutstr), S("infinite"))) {
             timeout = -1;
         } else {
             timeout = (time_t)atoi(timeoutstr); // TODO: use strtol
--- a/dav/scfg.c	Sat Sep 23 11:45:03 2017 +0200
+++ b/dav/scfg.c	Sun Sep 24 11:31:01 2017 +0200
@@ -137,6 +137,7 @@
     bool backuppull = false;
     bool lockpull = false;
     bool lockpush = false;
+    time_t lock_timeout = 0;
     
     unsigned short parentlineno = node->line;
     node = node->children;
@@ -183,6 +184,14 @@
                 lockpull = util_getboolean(value);
             } else if(xstreq(node->name, "lock-push")) {
                 lockpush = util_getboolean(value);
+            } else if(xstreq(node->name, "lock-timeout")) {
+                int64_t t = 0;
+                if(util_strtoint(value, &t)) {
+                    lock_timeout = (time_t)t;
+                } else {
+                    print_warning(node->line, "integer value "
+                            "expected in <lock-timeout> element\n");
+                }
             } else {
                 print_error(node->line,
                         "unknown directory config element: %s\n", node->name);
@@ -222,6 +231,7 @@
     dir->backuppull = backuppull;
     dir->lockpull = lockpull;
     dir->lockpush = lockpush;
+    dir->lock_timeout = lock_timeout;
     if (include) {
         dir->include = include;
     } else {
--- a/dav/scfg.h	Sat Sep 23 11:45:03 2017 +0200
+++ b/dav/scfg.h	Sun Sep 24 11:31:01 2017 +0200
@@ -49,6 +49,7 @@
     UcxList *include;
     UcxList *exclude;
     int max_retry;
+    time_t lock_timeout;
     bool backuppull;
     bool lockpull;
     bool lockpush;
--- a/dav/sync.c	Sat Sep 23 11:45:03 2017 +0200
+++ b/dav/sync.c	Sun Sep 24 11:31:01 2017 +0200
@@ -306,7 +306,7 @@
     DavResource *root = dav_resource_new(sn, "/");
     root->iscollection = TRUE;
     if((dir->lockpush || cmd_getoption(a, "lock")) && !cmd_getoption(a, "nolock")) {
-        if(dav_lock(root)) {
+        if(dav_lock_t(root, dir->lock_timeout)) {
             print_resource_error(sn, "/");
             dav_session_destroy(sn);
             fprintf(stderr, "Abort\n");
@@ -847,7 +847,7 @@
     DavBool locked = FALSE;
     char *locktokenfile = NULL;
     if((dir->lockpush || cmd_getoption(a, "lock")) && !cmd_getoption(a, "nolock")) {
-        if(dav_lock(root)) {
+        if(dav_lock_t(root, dir->lock_timeout)) {
             print_resource_error(sn, "/");
             dav_session_destroy(sn);
             fprintf(stderr, "Abort\n");

mercurial