Branch: Tag:

2004-05-15

2004-05-15 11:23:36 by Henrik Grubbström (Grubba) <grubba@grubba.org>

resource_id() and unregister_lock() may get called with a zero request id.
Timeouted locks seem to work now.

Rev: server/base_server/module.pike:1.212

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2001, Roxen IS. - // $Id: module.pike,v 1.211 2004/05/14 21:42:47 mast Exp $ + // $Id: module.pike,v 1.212 2004/05/15 11:23:36 grubba Exp $      #include <module_constants.h>   #include <module.h>
603:    return 0;   }    - string resource_id (string path, RequestID id) + string resource_id (string path, RequestID|int(0..0) id)   //! Return a string that within the filesystem uniquely identifies the   //! resource on @[path] in the given request. This is commonly @[path]   //! itself but can be extended with e.g. language, user or some form
630:   //! @param path   //! The requested path below the filesystem location. It has been   //! normalized with @[VFS.normalize_path]. + //! + //! @param id + //! The request id may have the value @expr{0@} (zero) if called + //! by @[Configuration()->expire_locks()].   {    return has_suffix (path, "/") ? path : path + "/";   }
951:   //! @param lock   //! The lock to unregister. (It must not be changed or destructed.)   //! - //! @returns - //! Returns a status mapping on any error, zero otherwise. - static void unregister_lock (string path, DAVLock lock, RequestID id) + //! @param id + //! The request id may have the value @expr{0@} (zero) if called + //! by @[Configuration()->expire_locks()]. + static void unregister_lock (string path, DAVLock lock, RequestID|int(0..0) id)   {    TRACE_ENTER(sprintf("unregister_lock(%O, lock(%O), X).", path, lock->locktoken),    this); -  mixed auth_user = authenticated_user_id (path, id); +  mixed auth_user = id && authenticated_user_id (path, id);    path = resource_id (path, id);    DAVLock removed_lock;    if (lock->recursive) { -  +  if (id) {    removed_lock = m_delete(prefix_locks[path], auth_user); -  +  } else { +  foreach(prefix_locks[path]; mixed user; DAVLock l) { +  if (l == lock) { +  removed_lock = m_delete(prefix_locks[path], user); +  } +  } +  }    if (!sizeof (prefix_locks[path])) m_delete (prefix_locks, path);    }    else if (file_locks[path]) { -  +  if (id) {    removed_lock = m_delete (file_locks[path], auth_user); -  +  } else { +  foreach(file_locks[path]; mixed user; DAVLock l) { +  if (l == lock) { +  removed_lock = m_delete(file_locks[path], user); +  } +  } +  }    if (!sizeof (file_locks[path])) m_delete (file_locks, path);    }    ASSERT_IF_DEBUG (lock /*%O*/ == removed_lock /*%O*/, lock, removed_lock);