Merge branch 'master' of ssh://git.samba.org/data/git/abartlet/samba into extended...
[abartlet/samba.git/.git] / source3 / smbd / close.c
index d4c531ab1955cbca0fe3e5c48d5951f7ae07ba46..f91f1fcf8fe143391d5d042ac91bcad814400552 100644 (file)
@@ -106,8 +106,7 @@ static void check_magic(struct files_struct *fsp)
 static NTSTATUS close_filestruct(files_struct *fsp)
 {
        NTSTATUS status = NT_STATUS_OK;
-       connection_struct *conn = fsp->conn;
-    
+
        if (fsp->fh->fd != -1) {
                if(flush_write_cache(fsp, CLOSE_FLUSH) == -1) {
                        status = map_nt_error_from_unix(errno);
@@ -115,9 +114,8 @@ static NTSTATUS close_filestruct(files_struct *fsp)
                delete_write_cache(fsp);
        }
 
-       conn->num_files_open--;
        return status;
-}    
+}
 
 /****************************************************************************
  If any deferred opens are waiting on this close, notify them.
@@ -583,7 +581,7 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
 
        DEBUG(2,("%s closed file %s (numopen=%d) %s\n",
                conn->server_info->unix_name,fsp->fsp_name,
-               conn->num_files_open,
+               conn->num_files_open - 1,
                nt_errstr(status) ));
 
        file_free(req, fsp);
@@ -696,6 +694,13 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                        fsp, NT_STATUS_OK);
        }
 
+       status = fd_close(fsp);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("Could not close dir! fname=%s, fd=%d, err=%d=%s\n",
+                         fsp->fsp_name, fsp->fh->fd, errno, strerror(errno)));
+       }
+
        /*
         * Do the code common to files and directories.
         */