summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-06-07 16:31:14 +0200
committerStefan Metzmacher <metze@samba.org>2012-06-15 03:28:13 +0200
commita7dccea0c5be8742c9e60c5caf6e832679e19f31 (patch)
tree44d400e44d016e4827a000998c1fa84530ef6d13
parent7aa9ad5bb9ce33c7e664582b5014917e84153314 (diff)
downloadsamba-a7dccea0c5be8742c9e60c5caf6e832679e19f31.tar.gz
samba-a7dccea0c5be8742c9e60c5caf6e832679e19f31.tar.bz2
samba-a7dccea0c5be8742c9e60c5caf6e832679e19f31.zip
s3:files: factor fsp_free() out of file_free()
To be reused in the durable reconnect code. Pair-Programmed-With: Volker Lendecke <vl@samba.org>
-rw-r--r--source3/smbd/files.c47
-rw-r--r--source3/smbd/proto.h1
2 files changed, 28 insertions, 20 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index c3a7465feb..12ec04cd3b 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -499,6 +499,32 @@ void file_sync_all(connection_struct *conn)
Free up a fsp.
****************************************************************************/
+void fsp_free(files_struct *fsp)
+{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+
+ DLIST_REMOVE(sconn->files, fsp);
+ SMB_ASSERT(sconn->num_files > 0);
+ sconn->num_files--;
+
+ TALLOC_FREE(fsp->fake_file_handle);
+
+ if (fsp->fh->ref_count == 1) {
+ TALLOC_FREE(fsp->fh);
+ } else {
+ fsp->fh->ref_count--;
+ }
+
+ fsp->conn->num_files_open--;
+
+ /* this is paranoia, just in case someone tries to reuse the
+ information */
+ ZERO_STRUCTP(fsp);
+
+ /* fsp->fsp_name is a talloc child and is free'd automatically. */
+ TALLOC_FREE(fsp);
+}
+
void file_free(struct smb_request *req, files_struct *fsp)
{
struct smbd_server_connection *sconn = fsp->conn->sconn;
@@ -538,26 +564,7 @@ void file_free(struct smb_request *req, files_struct *fsp)
/* Drop all remaining extensions. */
vfs_remove_all_fsp_extensions(fsp);
- DLIST_REMOVE(sconn->files, fsp);
- SMB_ASSERT(sconn->num_files > 0);
- sconn->num_files--;
-
- TALLOC_FREE(fsp->fake_file_handle);
-
- if (fsp->fh->ref_count == 1) {
- TALLOC_FREE(fsp->fh);
- } else {
- fsp->fh->ref_count--;
- }
-
- fsp->conn->num_files_open--;
-
- /* this is paranoia, just in case someone tries to reuse the
- information */
- ZERO_STRUCTP(fsp);
-
- /* fsp->fsp_name is a talloc child and is free'd automatically. */
- TALLOC_FREE(fsp);
+ fsp_free(fsp);
DEBUG(5,("freed files structure %d (%u used)\n",
fnum, (unsigned int)sconn->num_files));
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 7f341363f1..4d035179c5 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -387,6 +387,7 @@ files_struct *file_find_di_first(struct smbd_server_connection *sconn,
files_struct *file_find_di_next(files_struct *start_fsp);
bool file_find_subpath(files_struct *dir_fsp);
void file_sync_all(connection_struct *conn);
+void fsp_free(files_struct *fsp);
void file_free(struct smb_request *req, files_struct *fsp);
files_struct *file_fsp(struct smb_request *req, uint16 fid);
uint64_t fsp_persistent_id(const struct files_struct *fsp);