From ea14c9443178da9ae6ccbe71e573156396f6f699 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Apr 2013 16:24:15 -0700 Subject: In the struct smb_Dir destructor, use the fsp back pointer to release resources. Removes one use of dirfd(). Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider --- source3/smbd/dir.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index e6233166a0..7bca6bfd3d 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1447,18 +1447,21 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, static int smb_Dir_destructor(struct smb_Dir *dirp) { - if (dirp->dir) { -#ifdef HAVE_DIRFD - if (dirp->conn->sconn) { - files_struct *fsp = file_find_fd(dirp->conn->sconn, - dirfd(dirp->dir)); - if (fsp) { - /* The call below closes the underlying fd. */ - fsp->fh->fd = -1; + if (dirp->dir != NULL) { + SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); + if (dirp->fsp != NULL) { + /* + * The SMB_VFS_CLOSEDIR above + * closes the underlying fd inside + * dirp->fsp. + */ + dirp->fsp->fh->fd = -1; + if (dirp->fsp->dptr != NULL) { + SMB_ASSERT(dirp->fsp->dptr->dir_hnd == dirp); + dirp->fsp->dptr->dir_hnd = NULL; } + dirp->fsp = NULL; } -#endif - SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); } if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) { dirp->conn->sconn->searches.dirhandles_open--; -- cgit