From: Ralph Boehme Date: Mon, 28 Sep 2020 08:37:36 +0000 (+0200) Subject: smbd: use fh_[get|set]_refcount() X-Git-Tag: samba-4.14.0rc1~407 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdb91631185978664eaac0b79e3c6ab9ddff9079;p=thirdparty%2Fsamba.git smbd: use fh_[get|set]_refcount() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 92f122d8e3d..a0d05570da2 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -799,7 +799,7 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp, the same handle we only have one share mode. Ensure we only remove the share mode on the last close. */ - if (fsp->fh->ref_count == 1) { + if (fh_get_refcount(fsp->fh) == 1) { /* Should we return on error here... ? */ tmp = close_remove_share_mode(fsp, close_type); status = ntstatus_keeperror(status, tmp); diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 53775ce3cab..be45cc450f0 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -56,7 +56,7 @@ NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx, fsp->fsp_flags.use_ofd_locks = false; #endif - fsp->fh->ref_count = 1; + fh_set_refcount(fsp->fh, 1); fsp_set_fd(fsp, -1); fsp->fnum = FNUM_FIELD_INVALID; @@ -573,10 +573,11 @@ void fsp_free(files_struct *fsp) TALLOC_FREE(fsp->fake_file_handle); - if (fsp->fh->ref_count == 1) { + if (fh_get_refcount(fsp->fh) == 1) { TALLOC_FREE(fsp->fh); } else { - fsp->fh->ref_count--; + size_t new_refcount = fh_get_refcount(fsp->fh) - 1; + fh_set_refcount(fsp->fh, new_refcount); } if (fsp->lease != NULL) { @@ -787,13 +788,16 @@ NTSTATUS dup_file_fsp( uint32_t create_options, files_struct *to) { + size_t new_refcount; + /* this can never happen for print files */ SMB_ASSERT(from->print_file == NULL); TALLOC_FREE(to->fh); to->fh = from->fh; - to->fh->ref_count++; + new_refcount = fh_get_refcount(to->fh) + 1; + fh_set_refcount(to->fh, new_refcount); to->file_id = from->file_id; to->initial_allocation_size = from->initial_allocation_size; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 4d29da5659a..bf14f5dd454 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -854,7 +854,7 @@ NTSTATUS fd_close(files_struct *fsp) */ return NT_STATUS_OK; } - if (fsp->fh->ref_count > 1) { + if (fh_get_refcount(fsp->fh) > 1) { return NT_STATUS_OK; /* Shared handle. Only close last reference. */ }