From f69c6920d400acc3a31b778ab6cdb6b7da67adef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 14 Mar 2012 10:52:03 +0100 Subject: s3: Fix lock ordering in notify_add It's not necessary to keep the global notify record locked during the inotify and notify_onelevel.tdb operations. Signed-off-by: Stefan Metzmacher --- source3/smbd/notify_internal.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source3') diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c index 985ece36c1..7891601bfe 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -515,22 +515,12 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, struct notify_list *listel; size_t len; int depth; - struct db_record *rec; /* see if change notify is enabled at all */ if (notify == NULL) { return NT_STATUS_NOT_IMPLEMENTED; } - status = notify_fetch_locked(notify, &rec); - NT_STATUS_NOT_OK_RETURN(status); - - status = notify_load(notify, rec); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(rec); - return status; - } - /* cope with /. on the end of the path */ len = strlen(e.path); if (len > 1 && e.path[len-1] == '.' && e.path[len-2] == '/') { @@ -579,11 +569,23 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0, then we need to install it in the array used for the intra-samba notify handling */ if (e.filter != 0 || e.subdir_filter != 0) { - status = notify_add_array(notify, rec, &e, private_data, depth); - } + struct db_record *rec; + status = notify_fetch_locked(notify, &rec); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + status = notify_load(notify, rec); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(rec); + goto done; + } + status = notify_add_array(notify, rec, &e, private_data, + depth); + TALLOC_FREE(rec); + } + status = NT_STATUS_OK; done: - talloc_free(rec); talloc_free(tmp_path); return status; -- cgit