summaryrefslogtreecommitdiff
path: root/source/smbd/close.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/smbd/close.c')
-rw-r--r--source/smbd/close.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/source/smbd/close.c b/source/smbd/close.c
index b3244432ff5..3fc7fdb0599 100644
--- a/source/smbd/close.c
+++ b/source/smbd/close.c
@@ -3,6 +3,7 @@
file closing
Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Jeremy Allison 1992-2004.
+ Copyright (C) Volker Lendecke 2005
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -92,7 +93,7 @@ static int close_filestruct(files_struct *fsp)
connection_struct *conn = fsp->conn;
int ret = 0;
- if (fsp->fd != -1) {
+ if (fsp->fh->fd != -1) {
if(flush_write_cache(fsp, CLOSE_FLUSH) == -1)
ret = -1;
@@ -148,7 +149,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
{
share_mode_entry *share_entry = NULL;
size_t share_entry_count = 0;
- BOOL delete_on_close = False;
+ BOOL delete_file = False;
connection_struct *conn = fsp->conn;
int saved_errno = 0;
int err = 0;
@@ -156,6 +157,20 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
remove_pending_lock_requests_by_fid(fsp);
+ if (fsp->aio_write_behind) {
+ /*
+ * If we're finishing write behind on a close we can get a write
+ * error here, we must remember this.
+ */
+ int ret = wait_for_aio_completion(fsp);
+ if (ret) {
+ saved_errno = ret;
+ err1 = -1;
+ }
+ } else {
+ cancel_aio_by_fsp(fsp);
+ }
+
/*
* If we're flushing on a close we can get a write
* error here, we must remember this.
@@ -180,34 +195,16 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
lock_share_entry_fsp(fsp);
- if (fsp->delete_on_close) {
-
- /*
- * Modify the share mode entry for all files open
- * on this device and inode to tell other smbds we have
- * changed the delete on close flag. The last closer will delete the file
- * if flag is set.
- */
-
- NTSTATUS status =set_delete_on_close_over_all(fsp, fsp->delete_on_close);
- if (NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_OK))
- DEBUG(0,("close_normal_file: failed to change delete on close flag for file %s\n",
- fsp->fsp_name ));
- }
-
- share_entry_count = del_share_mode(fsp, &share_entry);
+ share_entry_count = del_share_mode(fsp, &share_entry,
+ &delete_file);
DEBUG(10,("close_normal_file: share_entry_count = %lu for file %s\n",
(unsigned long)share_entry_count, fsp->fsp_name ));
- /*
- * We delete on close if it's the last open, and the
- * delete on close flag was set in the entry we just deleted.
- */
-
- if ((share_entry_count == 0) && share_entry &&
- GET_DELETE_ON_CLOSE_FLAG(share_entry->share_mode) )
- delete_on_close = True;
+ if (share_entry_count != 0) {
+ /* We're not the last ones -- don't delete */
+ delete_file = False;
+ }
SAFE_FREE(share_entry);
@@ -219,7 +216,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
* reference to a file.
*/
- if (normal_close && delete_on_close) {
+ if (normal_close && delete_file) {
DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n",
fsp->fsp_name));
if(SMB_VFS_UNLINK(conn,fsp->fsp_name) != 0) {
@@ -297,7 +294,8 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
* reference to a directory also.
*/
- if (normal_close && fsp->directory_delete_on_close) {
+ if (normal_close &&
+ get_delete_on_close_flag(fsp->dev, fsp->inode)) {
BOOL ok = rmdir_internals(fsp->conn, fsp->fsp_name);
DEBUG(5,("close_directory: %s. Delete on close was set - deleting directory %s.\n",
fsp->fsp_name, ok ? "succeeded" : "failed" ));
@@ -307,8 +305,9 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
* now fail as the directory has been deleted.
*/
- if(ok)
+ if(ok) {
remove_pending_change_notify_requests_by_filename(fsp);
+ }
process_pending_change_notify_queue((time_t)0);
}
@@ -317,8 +316,9 @@ static int close_directory(files_struct *fsp, BOOL normal_close)
*/
close_filestruct(fsp);
- if (fsp->fsp_name)
+ if (fsp->fsp_name) {
string_free(&fsp->fsp_name);
+ }
file_free(fsp);
return 0;