fixes error detection loop in dav lock/unlock/get-property/set-property

Sun, 09 Jul 2017 16:24:48 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 09 Jul 2017 16:24:48 +0200
changeset 264
94c0a938b66c
parent 263
f24b730cb75e
child 265
ee9e63c437c4

fixes error detection loop in dav lock/unlock/get-property/set-property

dav lock was completely broken

dav/main.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sun Jul 02 21:35:01 2017 +0200
+++ b/dav/main.c	Sun Jul 09 16:24:48 2017 +0200
@@ -62,7 +62,7 @@
 #include <libidav/davqlparser.h>
 #include <libidav/davqlexec.h>
 void test() {
-    
+
 }
 
 int main(int argc, char **argv) {
@@ -1134,6 +1134,7 @@
             print_resource_error(sn, res->path);
             return -1;
         }
+        break;
     }
     
     char *value = namespace ?
@@ -1203,8 +1204,8 @@
             print_resource_error(sn, res->path);
             fprintf(stderr, "Cannot set property.\n");
             ret = -1;
-            break;
         }
+        break;
     }
     
     free(path);
@@ -1229,13 +1230,14 @@
     
     DavResource *res = dav_resource_new(sn, path);
     for(int i=0;i<2;i++) {
-        if(dav_lock(res)) {
-            if(i == 0 && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
-                continue;
-            }
-            print_resource_error(sn, res->path);
-            return -1;
+        if(!dav_lock(res)) {
+            break;
         }
+        if(i == 0 && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
+            continue;
+        }
+        print_resource_error(sn, res->path);
+        return -1;
     }
     
     DavLock *lock = dav_get_lock(sn, res->path);
@@ -1304,14 +1306,15 @@
     int ret = 0;
     DavResource *res = dav_resource_new(sn, path);
     for(int i=0;i<2;i++) {
-        if(dav_unlock(res)) {
-            if(i == 0 && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
-                continue;
-            }
-            print_resource_error(sn, res->path);
-            ret = -1;
+        if(!dav_unlock(res)) {
             break;
         }
+        if(i == 0 && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
+            continue;
+        }
+        print_resource_error(sn, res->path);
+        ret = -1;
+        break;
     }
     
     dav_session_destroy(sn);

mercurial