ASF Bugzilla – Attachment 27095 Details for
Bug 51297
Improve error handling during "UNLOCK"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch that improves error handling during "dav unlock"
improve-error-handling-during-unlock.patch (text/plain), 6.09 KB, created by
vijayaguru
on 2011-05-31 09:06:29 UTC
(
hide
)
Description:
patch that improves error handling during "dav unlock"
Filename:
MIME Type:
Creator:
vijayaguru
Created:
2011-05-31 09:06:29 UTC
Size:
6.09 KB
patch
obsolete
>Index: modules/dav/main/mod_dav.h >=================================================================== >--- modules/dav/main/mod_dav.h (revision 1127433) >+++ modules/dav/main/mod_dav.h (working copy) >@@ -1246,9 +1246,13 @@ > dav_lockdb *lockdb, > const apr_xml_doc *doc, > dav_lock **lock_request); >+/* Should we deprecate this? */ > DAV_DECLARE(int) dav_unlock(request_rec *r, > const dav_resource *resource, > const dav_locktoken *locktoken); >+DAV_DECLARE(dav_error *) dav_unlock2(request_rec *r, >+ const dav_resource *resource, >+ const dav_locktoken *locktoken); > DAV_DECLARE(dav_error *) dav_add_lock(request_rec *r, > const dav_resource *resource, > dav_lockdb *lockdb, dav_lock *request, >Index: modules/dav/main/util_lock.c >=================================================================== >--- modules/dav/main/util_lock.c (revision 1127433) >+++ modules/dav/main/util_lock.c (working copy) >@@ -475,17 +475,18 @@ > } > > /* >-** dav_unlock: Removes all direct and indirect locks for r->filename, >+** do_dav_unlock: Removes all direct and indirect locks for r->filename, > ** with given locktoken. If locktoken == null_locktoken, all locks > ** are removed. If r->filename represents an indirect lock, >-** we must unlock the appropriate direct lock. >+** we must unlock the appropriate direct lock. err is an outparam >+** which preserves error in case of any failures. > ** Returns OK or appropriate HTTP_* response and logs any errors. > ** > ** ### We've already crawled the tree to ensure everything was locked > ** by us; there should be no need to incorporate a rollback. > */ >-DAV_DECLARE(int) dav_unlock(request_rec *r, const dav_resource *resource, >- const dav_locktoken *locktoken) >+static int do_dav_unlock(request_rec *r, const dav_resource *resource, >+ const dav_locktoken *locktoken, dav_error **err) > { > int result; > dav_lockdb *lockdb; >@@ -494,10 +495,11 @@ > const dav_hooks_repository *repos_hooks = resource->hooks; > dav_walker_ctx ctx = { { 0 } }; > dav_response *multi_status; >- dav_error *err; >+ dav_error *err2; > > /* If no locks provider, then there is nothing to unlock. */ > if (hooks == NULL) { >+ *err = NULL; > return OK; > } > >@@ -513,19 +515,21 @@ > * Just start removing all locks at and below resource. > */ > >- if ((err = (*hooks->open_lockdb)(r, 0, 1, &lockdb)) != NULL) { >+ if ((err2 = (*hooks->open_lockdb)(r, 0, 1, &lockdb)) != NULL) { > /* ### return err! maybe add a higher-level desc */ > /* ### map result to something nice; log an error */ >+ *err = err2; > return HTTP_INTERNAL_SERVER_ERROR; > } > > if (locktoken != NULL >- && (err = dav_get_direct_resource(r->pool, lockdb, >- locktoken, resource, >- &lock_resource)) != NULL) { >+ && (err2 = dav_get_direct_resource(r->pool, lockdb, >+ locktoken, resource, >+ &lock_resource)) != NULL) { > /* ### add a higher-level desc? */ > /* ### should return err! */ >- return err->status; >+ *err = err2; >+ return err2->status; > } > > /* At this point, lock_resource/locktoken refers to a direct lock (key), ie >@@ -541,17 +545,53 @@ > ctx.r = r; > ctx.locktoken = locktoken; > >- err = (*repos_hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status); >+ err2 = (*repos_hooks->walk)(&ctx.w, DAV_INFINITY, &multi_status); > >- /* ### fix this! */ >- /* ### do something with multi_status */ >- result = err == NULL ? OK : err->status; >- > (*hooks->close_lockdb)(lockdb); >+ >+ if (err2 != NULL) { >+ *err = err2; >+ result = err2->status; >+ } >+ else { >+ *err = NULL; >+ result = OK; >+ } > > return result; > } >+ >+/* >+** dav_unlock: Wrapper function on do_dav_unlock(). >+** Removes all direct and indirect locks for r->filename, >+** with given locktoken. >+** >+** Returns OK or appropriate HTTP_* response. >+** >+** should we deprecate this? >+*/ >+DAV_DECLARE(int) dav_unlock(request_rec *r, const dav_resource *resource, >+ const dav_locktoken *locktoken) >+{ >+ dav_error *err; >+ return do_dav_unlock(r, resource, locktoken, &err); >+} > >+/* >+** dav_unlock2: Wrapper function on do_dav_unlock(). >+** Removes all direct and indirect locks for r->filename, >+** with given locktoken. >+** >+** Returns dav_error to the callers if an error occurs. >+*/ >+DAV_DECLARE(dav_error *) dav_unlock2(request_rec *r, const dav_resource *resource, >+ const dav_locktoken *locktoken) >+{ >+ dav_error *err; >+ do_dav_unlock(r, resource, locktoken, &err); >+ return err; >+} >+ > /* dav_inherit_walker: Walker callback function to inherit locks */ > static dav_error * dav_inherit_walker(dav_walk_resource *wres, int calltype) > { >Index: modules/dav/main/mod_dav.c >=================================================================== >--- modules/dav/main/mod_dav.c (revision 1127433) >+++ modules/dav/main/mod_dav.c (working copy) >@@ -3184,7 +3184,6 @@ > dav_error *err; > dav_resource *resource; > const dav_hooks_locks *locks_hooks; >- int result; > const char *const_locktoken_txt; > char *locktoken_txt; > dav_locktoken *locktoken = NULL; >@@ -3265,8 +3264,8 @@ > * For us, if r->filename represents an indirect lock (part of an infinity lock), > * we must actually perform an UNLOCK on the direct lock for this resource. > */ >- if ((result = dav_unlock(r, resource, locktoken)) != OK) { >- return result; >+ if ((err = dav_unlock2(r, resource, locktoken)) != NULL) { >+ return dav_handle_err(r, err, NULL); > } > > return HTTP_NO_CONTENT;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51297
: 27095