summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-01-09 14:30:53 +0100
committerJeremy Allison <jra@samba.org>2012-01-12 23:59:22 +0100
commit9cf6d735d43f6f905b19f52d38c93aa30092333d (patch)
treefd75eba7dc698d61b3f8d5ef240c31fef068f28a /source3/locking
parent540e51f77e07cc65b6b097f8ff01cd10f04644d0 (diff)
downloadsamba-9cf6d735d43f6f905b19f52d38c93aa30092333d.tar.gz
samba-9cf6d735d43f6f905b19f52d38c93aa30092333d.tar.bz2
samba-9cf6d735d43f6f905b19f52d38c93aa30092333d.zip
s3: Introduce get_share_mode_lock_fresh()
This slightly simplifies the code path for all callers which assume that a share mode exists already. Only the callers in open_file_ntcreate and open_directory will ever create new share modes. Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c30
-rw-r--r--source3/locking/proto.h11
2 files changed, 26 insertions, 15 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 95710cdd75..2e400ac8ef 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -675,6 +675,11 @@ static struct share_mode_lock *fresh_share_mode_lock(
{
struct share_mode_lock *lck;
+ if ((servicepath == NULL) || (smb_fname == NULL) ||
+ (old_write_time == NULL)) {
+ return NULL;
+ }
+
lck = talloc_zero(mem_ctx, struct share_mode_lock);
if (lck == NULL) {
goto fail;
@@ -703,11 +708,11 @@ fail:
return NULL;
}
-struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
- const struct file_id id,
- const char *servicepath,
- const struct smb_filename *smb_fname,
- const struct timespec *old_write_time)
+struct share_mode_lock *get_share_mode_lock_fresh(TALLOC_CTX *mem_ctx,
+ const struct file_id id,
+ const char *servicepath,
+ const struct smb_filename *smb_fname,
+ const struct timespec *old_write_time)
{
struct share_mode_lock *lck;
struct file_id tmp;
@@ -735,14 +740,18 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
TALLOC_FREE(rec);
return NULL;
}
-
lck->id = id;
lck->record = talloc_move(lck, &rec);
talloc_set_destructor(lck, share_mode_lock_destructor);
-
return lck;
}
+struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
+ const struct file_id id)
+{
+ return get_share_mode_lock_fresh(mem_ctx, id, NULL, NULL, NULL);
+}
+
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id)
{
@@ -1260,8 +1269,7 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct s
delete_on_close ? "Adding" : "Removing", fsp->fnum,
fsp_str_dbg(fsp)));
- lck = get_share_mode_lock(talloc_tos(), fsp->file_id, NULL, NULL,
- NULL);
+ lck = get_share_mode_lock(talloc_tos(), fsp->file_id);
if (lck == NULL) {
return False;
}
@@ -1314,7 +1322,7 @@ bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
- lck = get_share_mode_lock(talloc_tos(), fileid, NULL, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fileid);
if (lck == NULL) {
return False;
}
@@ -1337,7 +1345,7 @@ bool set_write_time(struct file_id fileid, struct timespec write_time)
convert_timespec_to_time_t(write_time)),
file_id_string_tos(&fileid)));
- lck = get_share_mode_lock(talloc_tos(), fileid, NULL, NULL, NULL);
+ lck = get_share_mode_lock(talloc_tos(), fileid);
if (lck == NULL) {
return False;
}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index d6f1c1bf4a..25f3d196b8 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -147,10 +147,13 @@ bool locking_init_readonly(void);
bool locking_end(void);
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
- const struct file_id id,
- const char *servicepath,
- const struct smb_filename *smb_fname,
- const struct timespec *old_write_time);
+ const struct file_id id);
+struct share_mode_lock *get_share_mode_lock_fresh(
+ TALLOC_CTX *mem_ctx,
+ const struct file_id id,
+ const char *servicepath,
+ const struct smb_filename *smb_fname,
+ const struct timespec *old_write_time);
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
const struct file_id id);
bool rename_share_filename(struct messaging_context *msg_ctx,