summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-04-10 16:24:15 -0700
committerAndreas Schneider <asn@samba.org>2013-04-12 14:33:11 +0200
commitea14c9443178da9ae6ccbe71e573156396f6f699 (patch)
tree3467c148433bcbe00df275e1f004337284303399 /source3
parente89ec641fc98ffd7f7193deb3728b0a284a093eb (diff)
downloadsamba-ea14c9443178da9ae6ccbe71e573156396f6f699.tar.gz
samba-ea14c9443178da9ae6ccbe71e573156396f6f699.tar.bz2
samba-ea14c9443178da9ae6ccbe71e573156396f6f699.zip
In the struct smb_Dir destructor, use the fsp back pointer to release resources.
Removes one use of dirfd(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/dir.c23
1 files changed, 13 insertions, 10 deletions
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--;