From: Volker Lendecke Date: Sat, 1 Jul 2017 06:27:57 +0000 (+0200) Subject: dbwrap_watch: Remove the "prec" parameter from watch_recv X-Git-Tag: talloc-2.1.11~329 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f8055f676a52b01a609611bbc3361442bb81a9b;p=thirdparty%2Fsamba.git dbwrap_watch: Remove the "prec" parameter from watch_recv The initial idea was to have some "atomicity" in this API. Every caller interested in a record would have to do something with it once it changes. However, only one caller really used this feature, and that is easily changed to not use it. So remove the complexity. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index be0a0d37e0b..3e91f46b428 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -1003,18 +1003,12 @@ static void dbwrap_watched_watch_done(struct tevent_req *subreq) } NTSTATUS dbwrap_watched_watch_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx, - struct db_record **prec, bool *blockerdead, struct server_id *blocker) { struct dbwrap_watched_watch_state *state = tevent_req_data( req, struct dbwrap_watched_watch_state); - struct db_watched_subrec *subrec; NTSTATUS status; - TDB_DATA key; - struct db_record *rec; - bool ok; if (tevent_req_is_nterror(req, &status)) { return status; @@ -1025,35 +1019,6 @@ NTSTATUS dbwrap_watched_watch_recv(struct tevent_req *req, if (blocker != NULL) { *blocker = state->blocker; } - if (prec == NULL) { - return NT_STATUS_OK; - } - - ok = dbwrap_record_watchers_key_parse(state->w_key, NULL, NULL, &key); - if (!ok) { - return NT_STATUS_INTERNAL_DB_ERROR; - } - - rec = dbwrap_fetch_locked(state->db, mem_ctx, key); - if (rec == NULL) { - return NT_STATUS_INTERNAL_DB_ERROR; - } - - talloc_set_destructor(state, NULL); - - subrec = talloc_get_type_abort( - rec->private_data, struct db_watched_subrec); - - ok = dbwrap_watched_remove_waiter(&subrec->wrec, state->me); - if (ok) { - status = dbwrap_watched_save(subrec->subrec, &subrec->wrec, - NULL, &subrec->wrec.data, 1, 0); - if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("dbwrap_watched_save failed: %s\n", - nt_errstr(status)); - } - } - - *prec = rec; return NT_STATUS_OK; } + diff --git a/source3/lib/dbwrap/dbwrap_watch.h b/source3/lib/dbwrap/dbwrap_watch.h index 1849310ab16..e94378f2d5a 100644 --- a/source3/lib/dbwrap/dbwrap_watch.h +++ b/source3/lib/dbwrap/dbwrap_watch.h @@ -32,8 +32,6 @@ struct tevent_req *dbwrap_watched_watch_send(TALLOC_CTX *mem_ctx, struct db_record *rec, struct server_id blocker); NTSTATUS dbwrap_watched_watch_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx, - struct db_record **prec, bool *blockerdead, struct server_id *blocker); diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index 8709052591d..c5d66e3855e 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -385,7 +385,7 @@ static void g_lock_lock_retry(struct tevent_req *subreq) struct g_lock_lock_fn_state fn_state; NTSTATUS status; - status = dbwrap_watched_watch_recv(subreq, NULL, NULL, NULL, NULL); + status = dbwrap_watched_watch_recv(subreq, NULL, NULL); DBG_DEBUG("watch_recv returned %s\n", nt_errstr(status)); TALLOC_FREE(subreq); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8c52f4bba56..e55c3941092 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2390,8 +2390,7 @@ static void defer_open_done(struct tevent_req *req) NTSTATUS status; bool ret; - status = dbwrap_watched_watch_recv(req, talloc_tos(), NULL, NULL, - NULL); + status = dbwrap_watched_watch_recv(req, NULL, NULL); TALLOC_FREE(req); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("dbwrap_watched_watch_recv returned %s\n", diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index db00ba0f672..0355095c8b1 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -279,8 +279,7 @@ static void defer_rename_done(struct tevent_req *subreq) int ret_size = 0; bool ok; - status = dbwrap_watched_watch_recv(subreq, state->req, NULL, NULL, - NULL); + status = dbwrap_watched_watch_recv(subreq, NULL, NULL); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("dbwrap_record_watch_recv returned %s\n", diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c index 24767483287..9e1fb6977b4 100644 --- a/source3/smbd/smbXsrv_session.c +++ b/source3/smbd/smbXsrv_session.c @@ -1129,7 +1129,7 @@ static void smb2srv_session_close_previous_modified(struct tevent_req *subreq) uint32_t global_id; NTSTATUS status; - status = dbwrap_watched_watch_recv(subreq, state, NULL, NULL, NULL); + status = dbwrap_watched_watch_recv(subreq, NULL, NULL); TALLOC_FREE(subreq); if (tevent_req_nterror(req, status)) { return; diff --git a/source3/torture/test_dbwrap_watch.c b/source3/torture/test_dbwrap_watch.c index 5aa0430b111..97d5ea6393c 100644 --- a/source3/torture/test_dbwrap_watch.c +++ b/source3/torture/test_dbwrap_watch.c @@ -90,8 +90,7 @@ bool run_dbwrap_watch1(int dummy) goto fail; } - status = dbwrap_watched_watch_recv(req, talloc_tos(), &rec, NULL, - NULL); + status = dbwrap_watched_watch_recv(req, NULL, NULL); if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "dbwrap_record_watch_recv failed: %s\n", nt_errstr(status));