From: Jeremy Allison Date: Wed, 17 Jul 2019 16:31:46 +0000 (-0700) Subject: s3: smbd: Use a separate simple destructor for the OpenDir() codepath. X-Git-Tag: tdb-1.4.2~499 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb5fa8ac8465e621c95da1f03b68da8aae73f6b0;p=thirdparty%2Fsamba.git s3: smbd: Use a separate simple destructor for the OpenDir() codepath. This will help greatly in understanding the code changes later. Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index f1065e3a75f..71cbfc6d10b 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1674,6 +1674,18 @@ static struct smb_Dir *open_dir_safely(TALLOC_CTX *ctx, return dir_hnd; } +/* + * Simple destructor for OpenDir() use. Don't need to + * care about fsp back pointer as we know we have never + * set it in the OpenDir() code path. + */ + +static int smb_Dir_OpenDir_destructor(struct smb_Dir *dir_hnd) +{ + SMB_VFS_CLOSEDIR(dir_hnd->conn, dir_hnd->dir); + return 0; +} + struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn, const struct smb_filename *smb_dname, const char *mask, @@ -1687,7 +1699,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn, if (dir_hnd == NULL) { return NULL; } - talloc_set_destructor(dir_hnd, smb_Dir_destructor); + talloc_set_destructor(dir_hnd, smb_Dir_OpenDir_destructor); return dir_hnd; }