mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
smbd: Simplify get_share_mode_lock a bit
This does two things: It gets rid of a talloc_stackframe in a hot code path and to me it makes the code easier to understand. It makes the talloc hierarchy more obvious to follow. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
fd94f82481
commit
7ae77a5d26
@ -369,36 +369,35 @@ struct share_mode_lock *get_share_mode_lock(
|
||||
const struct smb_filename *smb_fname,
|
||||
const struct timespec *old_write_time)
|
||||
{
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
struct share_mode_lock *lck;
|
||||
|
||||
lck = talloc(mem_ctx, struct share_mode_lock);
|
||||
if (lck == NULL) {
|
||||
DEBUG(1, ("talloc failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (the_lock == NULL) {
|
||||
the_lock = get_share_mode_lock_internal(
|
||||
frame, id, servicepath, smb_fname, old_write_time);
|
||||
lck, id, servicepath, smb_fname, old_write_time);
|
||||
if (the_lock == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
talloc_set_destructor(the_lock, the_lock_destructor);
|
||||
} else {
|
||||
if (talloc_reference(lck, the_lock) == NULL) {
|
||||
DEBUG(1, ("talloc_reference failed\n"));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (!file_id_equal(&the_lock->data->id, &id)) {
|
||||
DEBUG(1, ("Can not lock two share modes simultaneously\n"));
|
||||
goto fail;
|
||||
}
|
||||
lck = talloc(mem_ctx, struct share_mode_lock);
|
||||
if (lck == NULL) {
|
||||
DEBUG(1, ("talloc failed\n"));
|
||||
goto fail;
|
||||
}
|
||||
if (talloc_reference(lck, the_lock) == NULL) {
|
||||
DEBUG(1, ("talloc_reference failed\n"));
|
||||
goto fail;
|
||||
}
|
||||
lck->data = the_lock->data;
|
||||
TALLOC_FREE(frame);
|
||||
return lck;
|
||||
fail:
|
||||
TALLOC_FREE(frame);
|
||||
TALLOC_FREE(lck);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user