MCPcopy Create free account
hub / github.com/apache/httpd / dav_get_direct_resource

Function dav_get_direct_resource

modules/dav/main/util_lock.c:423–485  ·  view source on GitHub ↗

** dav_get_direct_resource: ** ** Find a lock on the specified resource, then return the resource the ** lock was applied to (in other words, given a (possibly) indirect lock, ** return the direct lock's corresponding resource). ** ** If the lock is an indirect lock, this usually means traversing up the ** namespace [repository] hierarchy. Note that some lock providers may be ** able to return thi

Source from the content-addressed store, hash-verified

421** able to return this information with a traversal.
422*/
423static dav_error * dav_get_direct_resource(apr_pool_t *p,
424 dav_lockdb *lockdb,
425 const dav_locktoken *locktoken,
426 const dav_resource *resource,
427 const dav_resource **direct_resource)
428{
429 if (lockdb->hooks->lookup_resource != NULL) {
430 return (*lockdb->hooks->lookup_resource)(lockdb, locktoken,
431 resource, direct_resource);
432 }
433
434 *direct_resource = NULL;
435
436 /* Find the top of this lock-
437 * If r->filename's direct locks include locktoken, use r->filename.
438 * If r->filename's indirect locks include locktoken, retry r->filename/..
439 * Else fail.
440 */
441 while (resource != NULL) {
442 dav_error *err;
443 dav_lock *lock;
444 dav_resource *parent;
445
446 /*
447 ** Find the lock specified by <locktoken> on <resource>. If it is
448 ** an indirect lock, then partial results are okay. We're just
449 ** trying to find the thing and know whether it is a direct or
450 ** an indirect lock.
451 */
452 if ((err = (*lockdb->hooks->find_lock)(lockdb, resource, locktoken,
453 1, &lock)) != NULL) {
454 /* ### add a higher-level desc? */
455 return err;
456 }
457
458 /* not found! that's an error. */
459 if (lock == NULL) {
460 return dav_new_error(p, HTTP_BAD_REQUEST, 0, 0,
461 "The specified locktoken does not correspond "
462 "to an existing lock on this resource.");
463 }
464
465 if (lock->rectype == DAV_LOCKREC_DIRECT) {
466 /* we found the direct lock. return this resource. */
467
468 *direct_resource = resource;
469 return NULL;
470 }
471
472 /* the lock was indirect. move up a level in the URL namespace */
473 if ((err = (*resource->hooks->get_parent_resource)(resource,
474 &parent)) != NULL) {
475 /* ### add a higher-level desc? */
476 return err;
477 }
478 resource = parent;
479 }
480

Callers 1

dav_unlockFunction · 0.85

Calls 1

dav_new_errorFunction · 0.85

Tested by

no test coverage detected