From aa875cfd7f81951f29c35574e949955ef983ba0e Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Tue, 10 Nov 2009 16:32:57 +0000 Subject: [PATCH] Revert removal of the key_type byte in the lock key. There is no need to break the format on systems without inodes. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@834533 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++-- modules/dav/fs/lock.c | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index f38e9cae2f..f9825dbf6f 100644 --- a/CHANGES +++ b/CHANGES @@ -30,8 +30,9 @@ Changes with Apache 2.3.3 old file if the transfer aborted. PR 39815. [Paul Querna, Stefan Fritsch] *) mod_dav_fs: Remove inode keyed locking as this conflicts with atomically - creating files. This is a format cange of the DavLockDB. The old - DavLockDB must be deleted on upgrade. [Stefan Fritsch] + creating files. On systems with inode numbers, this is a format cange of + the DavLockDB. The old DavLockDB must be deleted on upgrade. + [Stefan Fritsch] *) mod_log_config: Make ${cookie}C correctly match whole cookie names instead of substrings. PR 28037. [Dan Franklin , diff --git a/modules/dav/fs/lock.c b/modules/dav/fs/lock.c index 97aa7eab45..41dc5ed9e6 100644 --- a/modules/dav/fs/lock.c +++ b/modules/dav/fs/lock.c @@ -48,7 +48,8 @@ ** ** KEY ** -** The database is keyed by the full path. +** The database is keyed by a key_type unsigned char (DAV_TYPE_FNAME) +** followed by the full path. The key_type DAV_TYPE_INODE is not used anymore. ** ** VALUE ** @@ -80,6 +81,12 @@ #define DAV_LOCK_DIRECT 1 #define DAV_LOCK_INDIRECT 2 +/* + * not used anymore + * #define DAV_TYPE_INODE 10 + */ +#define DAV_TYPE_FNAME 11 + /* ack. forward declare. */ static dav_error * dav_fs_remove_locknull_member(apr_pool_t *p, @@ -379,8 +386,11 @@ static apr_datum_t dav_fs_build_key(apr_pool_t *p, /* ### does this allocation have a proper lifetime? need to check */ /* ### can we use a buffer for this? */ - key.dsize = strlen(pathname) + 1; - key.dptr = apr_pstrmemdup(p, pathname, key.dsize - 1); + /* size is TYPE + pathname + null */ + key.dsize = strlen(pathname) + 2; + key.dptr = apr_palloc(p, key.dsize); + *key.dptr = DAV_TYPE_FNAME; + memcpy(key.dptr + 1, pathname, key.dsize - 1); if (key.dptr[key.dsize - 2] == '/') key.dptr[--key.dsize - 1] = '\0'; return key; @@ -579,14 +589,15 @@ static dav_error * dav_fs_load_lock_record(dav_lockdb *lockdb, apr_datum_t key, need_save = DAV_TRUE; /* Remove timed-out locknull fm .locknull list */ - { + if (*key.dptr == DAV_TYPE_FNAME) { + const char *fname = key.dptr + 1; apr_finfo_t finfo; apr_status_t rv; /* if we don't see the file, then it's a locknull */ - rv = apr_stat(&finfo, key.dptr, APR_FINFO_MIN | APR_FINFO_LINK, p); + rv = apr_stat(&finfo, fname, APR_FINFO_MIN | APR_FINFO_LINK, p); if (rv != APR_SUCCESS && rv != APR_INCOMPLETE) { - if ((err = dav_fs_remove_locknull_member(p, key.dptr, &buf)) != NULL) { + if ((err = dav_fs_remove_locknull_member(p, fname, &buf)) != NULL) { /* ### push a higher-level description? */ return err; } -- 2.40.0