diff --git a/include/PoolSQL.h b/include/PoolSQL.h index 86c1fc0a05..86641daaa7 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -82,6 +82,20 @@ public: */ PoolObjectSQL * get(const string& name, int uid, bool lock); + /** + * Updates the cache name index. Must be called when the owner of an object + * is changed + * + * @param old_name Object's name before the change + * @param old_uid Object's owner ID before the change + * @param new_name Object's name after the change + * @param new_uid Object's owner ID after the change + */ + void update_cache_index(string& old_name, + int old_uid, + string& new_name, + int new_uid); + /** * Finds a set objects that satisfies a given condition * @param oids a vector with the oids of the objects. diff --git a/src/pool/PoolSQL.cc b/src/pool/PoolSQL.cc index e8f749e8a3..f763dd2b38 100644 --- a/src/pool/PoolSQL.cc +++ b/src/pool/PoolSQL.cc @@ -339,6 +339,32 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid, bool olock) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void PoolSQL::update_cache_index(string& old_name, + int old_uid, + string& new_name, + int new_uid) +{ + map::iterator index; + + lock(); + + string old_key = key(old_name, old_uid); + string new_key = key(new_name, new_uid); + + index = name_pool.find(old_key); + + if ( index != name_pool.end() ) + { + name_pool.erase(old_key); + name_pool.insert(make_pair(new_key, index->second)); + } + + unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void PoolSQL::replace() { bool removed = false; diff --git a/src/rm/RequestManagerChown.cc b/src/rm/RequestManagerChown.cc index f458cbbcf1..e1563dfd83 100644 --- a/src/rm/RequestManagerChown.cc +++ b/src/rm/RequestManagerChown.cc @@ -134,11 +134,16 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList, { failure_response(NO_EXISTS,get_error(object_name(auth_object),oid),att); return; - } + } if ( noid != -1 ) { + string obj_name = object->get_name(); + int old_uid = object->get_uid(); + object->set_user(noid,nuname); + + pool->update_cache_index(obj_name, old_uid, obj_name, noid); } if ( ngid != -1 ) @@ -273,4 +278,3 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList, return; } - \ No newline at end of file