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

Function dav_get_resource_state

modules/dav/main/util_lock.c:686–743  ·  view source on GitHub ↗

** dav_get_resource_state: Returns the state of the resource ** r->filename: DAV_RESOURCE_NULL, DAV_RESOURCE_LOCK_NULL, ** or DAV_RESOURCE_EXIST. ** ** Returns DAV_RESOURCE_ERROR if an error occurs. */

Source from the content-addressed store, hash-verified

684** Returns DAV_RESOURCE_ERROR if an error occurs.
685*/
686DAV_DECLARE(int) dav_get_resource_state(request_rec *r,
687 const dav_resource *resource)
688{
689 const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r);
690
691 if (resource->exists)
692 return DAV_RESOURCE_EXISTS;
693
694 if (hooks != NULL) {
695 dav_error *err;
696 dav_lockdb *lockdb;
697 int locks_present;
698
699 /*
700 ** A locknull resource has the form:
701 **
702 ** known-dir "/" locknull-file
703 **
704 ** It would be nice to look into <resource> to verify this form,
705 ** but it does not have enough information for us. Instead, we
706 ** can look at the path_info. If the form does not match, then
707 ** there is no way we could have a locknull resource -- it must
708 ** be a plain, null resource.
709 **
710 ** Apache sets r->filename to known-dir/unknown-file and r->path_info
711 ** to "" for the "proper" case. If anything is in path_info, then
712 ** it can't be a locknull resource.
713 **
714 ** ### I bet this path_info hack doesn't work for repositories.
715 ** ### Need input from repository implementors! What kind of
716 ** ### restructure do we need? New provider APIs?
717 */
718 if (r->path_info != NULL && *r->path_info != '\0') {
719 return DAV_RESOURCE_NULL;
720 }
721
722 if ((err = (*hooks->open_lockdb)(r, 1, 1, &lockdb)) == NULL) {
723 /* note that we might see some expired locks... *shrug* */
724 err = (*hooks->has_locks)(lockdb, resource, &locks_present);
725 (*hooks->close_lockdb)(lockdb);
726 }
727
728 if (err != NULL) {
729 /* ### don't log an error. return err. add higher-level desc. */
730
731 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00623)
732 "Failed to query lock-null status for %s",
733 r->filename);
734
735 return DAV_RESOURCE_ERROR;
736 }
737
738 if (locks_present)
739 return DAV_RESOURCE_LOCK_NULL;
740 }
741
742 return DAV_RESOURCE_NULL;
743}

Callers 9

dav_method_putFunction · 0.85
dav_method_optionsFunction · 0.85
dav_method_propfindFunction · 0.85
dav_method_mkcolFunction · 0.85
dav_method_copymoveFunction · 0.85
dav_method_lockFunction · 0.85
dav_method_unlockFunction · 0.85
dav_method_vsn_controlFunction · 0.85
dav_validate_requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected