Skip to content
Snippets Groups Projects
Commit 84af637a authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Rename user_cache_find to user_by_id().

Rename user_cache_find to user_by_id() to be consistent
with func_by_id(), space_by_id() - API variant which
does not throw exceptions if an object is not found.
parent 4485c234
No related branches found
No related tags found
No related merge requests found
......@@ -1273,7 +1273,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event)
uint32_t uid = tuple_field_u32(old_tuple ?
old_tuple : new_tuple, ID);
struct user_def *old_user = user_cache_find(uid);
struct user_def *old_user = user_by_id(uid);
if (new_tuple != NULL && old_user == NULL) { /* INSERT */
struct user_def user;
user_create_from_tuple(&user, new_tuple);
......@@ -1436,8 +1436,8 @@ priv_def_create_from_tuple(struct priv_def *priv, struct tuple *tuple)
static void
priv_def_check(struct priv_def *priv)
{
struct user_def *grantor = user_cache_find(priv->grantor_id);
struct user_def *grantee = user_cache_find(priv->grantee_id);
struct user_def *grantor = user_by_id(priv->grantor_id);
struct user_def *grantee = user_by_id(priv->grantee_id);
if (grantor == NULL) {
tnt_raise(ClientError, ER_NO_SUCH_USER,
int2str(priv->grantor_id));
......@@ -1484,7 +1484,7 @@ priv_def_check(struct priv_def *priv)
static void
grant_or_revoke(struct priv_def *priv)
{
struct user_def *grantee = user_cache_find(priv->grantee_id);
struct user_def *grantee = user_by_id(priv->grantee_id);
if (grantee == NULL)
return;
struct access *access = NULL;
......
......@@ -524,7 +524,7 @@ SetuidGuard::SetuidGuard(const char *name, uint32_t name_len,
/** Remember and change the current user id. */
if (unlikely(func->auth_token >= BOX_USER_MAX)) {
/* Optimization: cache auth_token on first access */
struct user_def *owner = user_cache_find(func->uid);
struct user_def *owner = user_by_id(func->uid);
assert(owner != NULL); /* checked by user_has_data() */
func->auth_token = owner->auth_token;
assert(owner->auth_token < BOX_USER_MAX);
......
......@@ -72,7 +72,7 @@ lbox_session_uid(struct lua_State *L)
static int
lbox_session_user(struct lua_State *L)
{
struct user_def *user = user_cache_find(session()->uid);
struct user_def *user = user_by_id(session()->uid);
if (user)
lua_pushstring(L, user->name);
else
......@@ -98,7 +98,7 @@ lbox_session_su(struct lua_State *L)
tnt_raise(ClientError, ER_NO_SUCH_USER, name);
} else {
uint32_t uid = lua_tointeger(L, 1);;
user = user_cache_find(uid);
user = user_by_id(uid);
if (user == NULL) {
tnt_raise(ClientError, ER_NO_SUCH_USER,
int2str(uid));
......
......@@ -81,7 +81,7 @@ user_map_put_slot(uint8_t auth_token)
void
user_cache_replace(struct user_def *user)
{
struct user_def *old = user_cache_find(user->uid);
struct user_def *old = user_by_id(user->uid);
if (old == NULL) {
uint8_t auth_token = user_map_get_slot();
old = users + auth_token;
......@@ -98,7 +98,7 @@ user_cache_replace(struct user_def *user)
void
user_cache_delete(uint32_t uid)
{
struct user_def *old = user_cache_find(uid);
struct user_def *old = user_by_id(uid);
if (old) {
assert(old->auth_token > ADMIN);
user_map_put_slot(old->auth_token);
......@@ -110,7 +110,7 @@ user_cache_delete(uint32_t uid)
/** Find user by id. */
struct user_def *
user_cache_find(uint32_t uid)
user_by_id(uint32_t uid)
{
mh_int_t k = mh_i32ptr_find(user_registry, uid, NULL);
if (k == mh_end(user_registry))
......@@ -123,7 +123,7 @@ struct user_def *
user_by_name(const char *name, uint32_t len)
{
uint32_t uid = schema_find_id(SC_USER_ID, 2, name, len);
struct user_def *user = user_cache_find(uid);
struct user_def *user = user_by_id(uid);
return user && user->type == SC_USER ? user : NULL;
}
......
......@@ -68,7 +68,7 @@ user_cache_delete(uint32_t uid);
/** Find user by id. */
struct user_def *
user_cache_find(uint32_t uid);
user_by_id(uint32_t uid);
/* Find a user by name. Used by authentication. */
struct user_def *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment