diff -r 99a34860c105 -r d938228c382e src/server/webdav/operation.c --- a/src/server/webdav/operation.c Wed Nov 02 19:19:01 2022 +0100 +++ b/src/server/webdav/operation.c Sun Nov 06 15:53:32 2022 +0100 @@ -30,7 +30,7 @@ #include #include -#include +#include #include "../daemon/session.h" #include "../util/pblock.h" @@ -60,7 +60,7 @@ Request *rq, WebdavBackend *dav, WebdavPList *reqprops, - UcxList *requests, + WebdavPropfindRequestList *requests, WebdavResponse *response) { WebdavOperation *op = pool_malloc(sn->pool, sizeof(WebdavOperation)); @@ -94,7 +94,7 @@ op->parent = parent; // get first propfind object - WebdavPropfindRequest *propfind = op->requests->data; + WebdavPropfindRequest *propfind = op->requests->propfind; // execute propfind_do of the first backend for the first resource int ret = REQ_PROCEED; @@ -117,6 +117,7 @@ char *path; size_t hreflen; size_t pathlen; + struct PathSearchElm *next; } PathSearchElm; /* @@ -187,7 +188,7 @@ const char *href, const char *path) { - WebdavPropfindRequest *request = op->requests->data; + WebdavPropfindRequest *request = op->requests->propfind; return webdav_op_iterate_children( vfs, request->depth, href, path, propfind_child_cb, op); } @@ -199,13 +200,13 @@ // start with second backend and request, because // the first one was already called by webdav_op_propfind_begin WebdavBackend *dav = op->dav->next; - UcxList *request = op->requests->next; + WebdavPropfindRequestList *request = op->requests->next; // call propfind_do of all remaining backends int ret = REQ_PROCEED; while(dav && request) { if(dav->propfind_do( - request->data, + request->propfind, op->response, op->parent, resource, @@ -225,11 +226,11 @@ */ int webdav_op_propfind_finish(WebdavOperation *op) { WebdavBackend *dav = op->dav; - UcxList *requests = op->requests; + WebdavPropfindRequestList *requests = op->requests; int ret = REQ_PROCEED; while(dav && requests) { - if(dav->propfind_finish(requests->data)) { + if(dav->propfind_finish(requests->propfind)) { ret = REQ_ABORTED; } @@ -274,7 +275,7 @@ const char *path) { WebdavProppatchRequest *orig_request = op->proppatch; - UcxAllocator *a = session_get_allocator(op->sn); + CxAllocator *a = pool_allocator(op->sn->pool); // create WebdavResource object for the requested resource WebdavResource *resource = op->response->addresource(op->response, href); @@ -499,7 +500,6 @@ vfs_op_child_func func, void *userdata) { - UcxAllocator *a = session_get_allocator(vfs->sn); pool_handle_t *pool = vfs->sn->pool; PathSearchElm *start_elm = pool_malloc(pool, sizeof(PathSearchElm)); @@ -507,12 +507,10 @@ start_elm->path = pool_strdup(pool, path ? path : ""); start_elm->hreflen = href ? strlen(href) : 0; start_elm->pathlen = path ? strlen(path) : 0; + start_elm->next = NULL; - UcxList *stack = ucx_list_prepend_a(a, NULL, start_elm); - UcxList *stack_end = stack; - if(!stack) { - return 1; - } + PathSearchElm *stack = start_elm; + PathSearchElm *stack_end = start_elm; // reusable buffer for full child path and href char *newpath = pool_malloc(pool, 256); @@ -523,7 +521,7 @@ int err = 0; while(stack && !err) { - PathSearchElm *cur_elm = stack->data; + PathSearchElm *cur_elm = stack; // when newpath is initialized with the parent path // set path_buf_init to TRUE @@ -596,38 +594,41 @@ PathSearchElm *new_elm = pool_malloc(pool, sizeof(PathSearchElm)); + if(!new_elm) { + err = 1; + break; + } new_elm->href = hrefcp; new_elm->path = pathcp; new_elm->hreflen = childhreflen; new_elm->pathlen = childpathlen; + new_elm->next = NULL; // add the new_elm to the stack - // stack_end is always not NULL here, because we remove + // stack_end is always not NULL here, because the loop is + // running as long as we have a stack and we remove // the first stack element at the end of the loop - UcxList *newlistelm = ucx_list_append_a(a, stack_end, new_elm); - if(!newlistelm) { - err = 1; - break; - } - stack_end = newlistelm; + stack_end->next = new_elm; + stack_end = new_elm; } } vfs_closedir(dir); + stack = stack->next; + pool_free(pool, cur_elm->path); pool_free(pool, cur_elm->href); pool_free(pool, cur_elm); - - stack = ucx_list_remove_a(a, stack, stack); } // in case of an error, we have to free all remaining stack elements - UCX_FOREACH(elm, stack) { - char *data = elm->data; - if(data != path) { - pool_free(pool, data); - } + for(PathSearchElm *elm=stack;elm;) { + PathSearchElm *next_elm = elm->next; + pool_free(pool, elm->path); + pool_free(pool, elm->href); + pool_free(pool, elm); + elm = next_elm; } return err;