From 630f1228d17c282a3661de050801b3aaf642accf Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 23 Jan 2024 15:19:12 +0100 Subject: [PATCH] smbd: move target code out of loop body Reduces indentation of the code code that is run in this function and prepares for adding more of it. Review with: git show -w Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- source3/smbd/conn.c | 64 ++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index 6694147c225..cb3c798084d 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -168,42 +168,46 @@ connection_struct *conn_new(struct smbd_server_connection *sconn) static void conn_clear_vuid_cache(connection_struct *conn, uint64_t vuid) { + struct vuid_cache_entry *ent = NULL; int i; for (i=0; ivuid_cache->array[i]; - - if (ent->vuid == vuid) { - ent->vuid = UID_FIELD_INVALID; - /* - * We need to keep conn->session_info around - * if it's equal to ent->session_info as a SMBulogoff - * is often followed by a SMBtdis (with an invalid - * vuid). The debug code (or regular code in - * vfs_full_audit) wants to refer to the - * conn->session_info pointer to print debug - * statements. Theoretically this is a bug, - * as once the vuid is gone the session_info - * on the conn struct isn't valid any more, - * but there's enough code that assumes - * conn->session_info is never null that - * it's easier to hold onto the old pointer - * until we get a new sessionsetupX. - * As everything is hung off the - * conn pointer as a talloc context we're not - * leaking memory here. See bug #6315. JRA. - */ - if (conn->session_info == ent->session_info) { - ent->session_info = NULL; - } else { - TALLOC_FREE(ent->session_info); - } - ent->read_only = False; - ent->share_access = 0; + if (ent->vuid != vuid) { + continue; } } + if (i == VUID_CACHE_SIZE) { + return; + } + + ent->vuid = UID_FIELD_INVALID; + + /* + * We need to keep conn->session_info around + * if it's equal to ent->session_info as a SMBulogoff + * is often followed by a SMBtdis (with an invalid + * vuid). The debug code (or regular code in + * vfs_full_audit) wants to refer to the + * conn->session_info pointer to print debug + * statements. Theoretically this is a bug, + * as once the vuid is gone the session_info + * on the conn struct isn't valid any more, + * but there's enough code that assumes + * conn->session_info is never null that + * it's easier to hold onto the old pointer + * until we get a new sessionsetupX. + * As everything is hung off the + * conn pointer as a talloc context we're not + * leaking memory here. See bug #6315. JRA. + */ + if (conn->session_info == ent->session_info) { + ent->session_info = NULL; + } else { + TALLOC_FREE(ent->session_info); + } + ent->read_only = False; + ent->share_access = 0; } /****************************************************************************