diff options
author | Volker Lendecke <vl@samba.org> | 2022-02-02 12:27:50 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2022-02-14 17:46:14 +0000 |
commit | 9794341b29e68726f6c4c8989b0a1e0db913d815 (patch) | |
tree | e618a661e75262b0fea893cca650a49fb384e20c | |
parent | c0e02d8e8794e54556adb7ff260c7080dda19e2a (diff) | |
download | samba-9794341b29e68726f6c4c8989b0a1e0db913d815.tar.gz |
smbd: Factor out close_file_in_loop() from file_close_conn_fn()
To be reused in file_close_user(). Deliberately a separate commit to
make the previous commit easier to understand.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14975
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 61f57ba24ee2e54abf224118f93bd0ccda44ec41)
-rw-r--r-- | source3/smbd/files.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 7a2123f3fae..1d03fa82076 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -752,32 +752,8 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/**************************************************************************** - Close all open files for a connection. -****************************************************************************/ - -struct file_close_conn_state { - struct connection_struct *conn; - bool fsp_left_behind; -}; - -static struct files_struct *file_close_conn_fn( - struct files_struct *fsp, - void *private_data) +static bool close_file_in_loop(struct files_struct *fsp) { - struct file_close_conn_state *state = private_data; - - if (fsp->conn != state->conn) { - return NULL; - } - - if (fsp->op != NULL && fsp->op->global->durable) { - /* - * A tree disconnect closes a durable handle - */ - fsp->op->global->durable = false; - } - if (fsp->base_fsp != NULL) { /* * This is a stream, it can't be a base @@ -815,11 +791,45 @@ static struct files_struct *file_close_conn_fn( * Have us called back a second time. In the second * round, "fsp" now looks like a normal fsp. */ - state->fsp_left_behind = true; - return NULL; + return false; } close_file_free(NULL, &fsp, SHUTDOWN_CLOSE); + return true; +} + +/**************************************************************************** + Close all open files for a connection. +****************************************************************************/ + +struct file_close_conn_state { + struct connection_struct *conn; + bool fsp_left_behind; +}; + +static struct files_struct *file_close_conn_fn( + struct files_struct *fsp, + void *private_data) +{ + struct file_close_conn_state *state = private_data; + bool did_close; + + if (fsp->conn != state->conn) { + return NULL; + } + + if (fsp->op != NULL && fsp->op->global->durable) { + /* + * A tree disconnect closes a durable handle + */ + fsp->op->global->durable = false; + } + + did_close = close_file_in_loop(fsp); + if (!did_close) { + state->fsp_left_behind = true; + } + return NULL; } |