[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Oct 18 22:29:02 UTC 2019


The branch, master has been updated
       via  0afd655e802 dbwrap_watch: Fix cleaning up dead watchers
       via  75433f60522 dbwrap_watch: Test cleanup of dead watchers
      from  50f69b60549 librpc:core: Make dcesrv_find_endpoint public

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0afd655e80262ea8505a2e6d0dd9cc453fbdfd8c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 15 10:56:54 2019 +0200

    dbwrap_watch: Fix cleaning up dead watchers
    
    "wrec->num_watchers" changes in dbwrap_watch_rec_del_watcher(). In
    32d6cc84c I forgot to update the copy of that variable.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Oct 18 22:28:07 UTC 2019 on sn-devel-184

commit 75433f60522b935adb8c14fc6d0caa14c85281b3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 15 10:55:25 2019 +0200

    dbwrap_watch: Test cleanup of dead watchers
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/dbwrap/dbwrap_watch.c   |   1 +
 source3/selftest/tests.py           |   1 +
 source3/torture/proto.h             |   1 +
 source3/torture/test_dbwrap_watch.c | 103 ++++++++++++++++++++++++++++++++++++
 source3/torture/torture.c           |   4 ++
 5 files changed, 110 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index 36e445a4fd3..c5d55a3c93d 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -433,6 +433,7 @@ static void dbwrap_watched_subrec_wakeup(
 		}
 		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
 			dbwrap_watch_rec_del_watcher(wrec, i);
+			num_to_wakeup -= 1;
 			continue;
 		}
 
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 7b600ec64a2..a7b098d6518 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -213,6 +213,7 @@ local_tests = [
     "LOCAL-CANONICALIZE-PATH",
     "LOCAL-DBWRAP-WATCH1",
     "LOCAL-DBWRAP-WATCH2",
+    "LOCAL-DBWRAP-WATCH3",
     "LOCAL-DBWRAP-DO-LOCKED1",
     "LOCAL-G-LOCK1",
     "LOCAL-G-LOCK2",
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 578d784b410..f1896d5624e 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -113,6 +113,7 @@ bool run_notify_bench2(int dummy);
 bool run_notify_bench3(int dummy);
 bool run_dbwrap_watch1(int dummy);
 bool run_dbwrap_watch2(int dummy);
+bool run_dbwrap_watch3(int dummy);
 bool run_dbwrap_do_locked1(int dummy);
 bool run_idmap_tdb_common_test(int dummy);
 bool run_local_dbwrap_ctdb(int dummy);
diff --git a/source3/torture/test_dbwrap_watch.c b/source3/torture/test_dbwrap_watch.c
index 5ef6b105ca2..cdfd8117522 100644
--- a/source3/torture/test_dbwrap_watch.c
+++ b/source3/torture/test_dbwrap_watch.c
@@ -175,3 +175,106 @@ fail:
 	TALLOC_FREE(ev);
 	return ret;
 }
+
+/*
+ * Test autocleanup of dead watchers
+ */
+
+bool run_dbwrap_watch3(int dummy)
+{
+	struct tevent_context *ev = NULL;
+	struct messaging_context *msg = NULL;
+	struct db_context *backend = NULL;
+	struct db_context *db = NULL;
+	const char *keystr = "key";
+	TDB_DATA key = string_term_tdb_data(keystr);
+	NTSTATUS status;
+	bool ret = false;
+	pid_t child, waited;
+	int wstatus, exit_status;
+
+	BlockSignals(true, SIGCHLD);
+
+	child = fork();
+	if (child == -1) {
+		fprintf(stderr,
+			"fork failed: %s\n",
+			strerror(errno));
+		goto fail;
+	}
+
+	ev = samba_tevent_context_init(talloc_tos());
+	if (ev == NULL) {
+		fprintf(stderr, "tevent_context_init failed\n");
+		goto fail;
+	}
+	msg = messaging_init(ev, ev);
+	if (msg == NULL) {
+		fprintf(stderr, "messaging_init failed\n");
+		goto fail;
+	}
+	backend = db_open(msg, "test_watch.tdb", 0, TDB_CLEAR_IF_FIRST,
+			  O_CREAT|O_RDWR, 0644, DBWRAP_LOCK_ORDER_1,
+			  DBWRAP_FLAG_NONE);
+	if (backend == NULL) {
+		fprintf(stderr, "db_open failed: %s\n", strerror(errno));
+		goto fail;
+	}
+
+	db = db_open_watched(ev, &backend, msg);
+	if (db == NULL) {
+		fprintf(stderr, "db_open_watched failed\n");
+		goto fail;
+	}
+
+	if (child == 0) {
+		struct db_record *rec = dbwrap_fetch_locked(db, db, key);
+		struct tevent_req *req = NULL;
+
+		if (rec == NULL) {
+			fprintf(stderr, "dbwrap_fetch_locked failed\n");
+			exit(1);
+		}
+
+		req = dbwrap_watched_watch_send(
+			db, ev, rec, (struct server_id) { 0 });
+		if (req == NULL) {
+			fprintf(stderr, "dbwrap_watched_watch_send failed\n");
+			exit(2);
+		}
+
+		exit(0);
+	}
+
+	waited = waitpid(child, &wstatus, 0);
+	if (waited == -1) {
+		fprintf(stderr, "waitpid failed: %s\n", strerror(errno));
+		goto fail;
+	}
+	if (!WIFEXITED(wstatus)) {
+		fprintf(stderr, "child did not exit normally\n");
+		goto fail;
+	}
+
+	exit_status = WEXITSTATUS(wstatus);
+	if (exit_status != 0) {
+		fprintf(stderr, "exit status is %d\n", exit_status);
+		goto fail;
+	}
+
+	status = dbwrap_store_uint32_bystring(db, keystr, 1);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		fprintf(stderr,
+			"dbwrap_store_uint32 returned %s\n",
+			nt_errstr(status));
+		goto fail;
+	}
+
+	(void)unlink("test_watch.tdb");
+	ret = true;
+fail:
+	TALLOC_FREE(db);
+	TALLOC_FREE(msg);
+	TALLOC_FREE(ev);
+	return ret;
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index e498c162f11..bfc2a2e24c9 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -14663,6 +14663,10 @@ static struct {
 		.name  = "LOCAL-DBWRAP-WATCH2",
 		.fn    = run_dbwrap_watch2,
 	},
+	{
+		.name  = "LOCAL-DBWRAP-WATCH3",
+		.fn    = run_dbwrap_watch3,
+	},
 	{
 		.name  = "LOCAL-DBWRAP-DO-LOCKED1",
 		.fn    = run_dbwrap_do_locked1,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list