[PATCH] some cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Oct 20 11:58:42 UTC 2017


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From b832a9f1f8de6397c62f58de4be1b477da98b730 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Oct 2017 17:02:56 +0200
Subject: [PATCH 1/5] smbd: cleanupdb.c is used in smbd only

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/wscript_build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index e9852f04f11..be0811f8737 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -412,7 +412,6 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                           lib/idmap_cache.c
                           lib/util_ea.c
                           lib/background.c
-                          lib/cleanupdb.c
                           ''',
                    deps='''
                         samba3util
@@ -670,6 +669,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
                           printing/printspoolss.c
                           lib/sessionid_tdb.c
                           lib/conn_tdb.c
+                          lib/cleanupdb.c
                           smbd/fake_file.c
                           smbd/quotas.c
                           smbd/ntquotas.c
-- 
2.11.0


From d459248f62d322fee764ae9c5e8e8eb126f374b6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Oct 2017 16:56:49 +0200
Subject: [PATCH 2/5] smbd: Simplify cleanupdb a bit

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/cleanupdb.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/source3/lib/cleanupdb.c b/source3/lib/cleanupdb.c
index 7bf7c7e7080..3250d609d03 100644
--- a/source3/lib/cleanupdb.c
+++ b/source3/lib/cleanupdb.c
@@ -24,8 +24,6 @@ struct cleanup_key {
 };
 
 struct cleanup_rec {
-	/* Storing the pid here as well saves a few lines of code */
-	pid_t pid;
 	bool unclean;
 };
 
@@ -59,7 +57,7 @@ bool cleanupdb_store_child(const pid_t pid, const bool unclean)
 {
 	struct tdb_wrap *db;
 	struct cleanup_key key = { .pid = pid };
-	struct cleanup_rec rec = { .pid = pid, .unclean = unclean };
+	struct cleanup_rec rec = { .unclean = unclean };
 	TDB_DATA tdbkey = { .dptr = (uint8_t *)&key, .dsize = sizeof(key) };
 	TDB_DATA tdbdata = { .dptr = (uint8_t *)&rec, .dsize = sizeof(rec) };
 	int result;
@@ -99,20 +97,6 @@ bool cleanupdb_delete_child(const pid_t pid)
 	return true;
 }
 
-static bool cleanup_rec_parse(TDB_DATA tdbdata,
-			      struct cleanup_rec *cleanup_rec)
-{
-	if (tdbdata.dsize != sizeof(struct cleanup_rec)) {
-		DBG_ERR("Found invalid value length %d in cleanup.tdb\n",
-			(int)tdbdata.dsize);
-		return false;
-	}
-
-	memcpy(cleanup_rec, tdbdata.dptr, sizeof(struct cleanup_rec));
-
-	return true;
-}
-
 struct cleanup_read_state {
 	int (*fn)(const pid_t pid, const bool cleanup, void *private_data);
 	void *private_data;
@@ -124,16 +108,25 @@ static int cleanup_traverse_fn(struct tdb_context *tdb,
 {
 	struct cleanup_read_state *state =
 		(struct cleanup_read_state *)private_data;
+	struct cleanup_key ckey;
 	struct cleanup_rec rec;
-	bool ok;
 	int result;
 
-	ok = cleanup_rec_parse(value, &rec);
-	if (!ok) {
+	if (key.dsize != sizeof(struct cleanup_key)) {
+		DBG_ERR("Found invalid key length %zu in cleanup.tdb\n",
+			key.dsize);
+		return -1;
+	}
+	memcpy(&ckey, key.dptr, sizeof(struct cleanup_key));
+
+	if (value.dsize != sizeof(struct cleanup_rec)) {
+		DBG_ERR("Found invalid value length %zu in cleanup.tdb\n",
+			value.dsize);
 		return -1;
 	}
+	memcpy(&rec, value.dptr, sizeof(struct cleanup_rec));
 
-	result = state->fn(rec.pid, rec.unclean, state->private_data);
+	result = state->fn(ckey.pid, rec.unclean, state->private_data);
 	if (result != 0) {
 		return -1;
 	}
-- 
2.11.0


From 81873157171295814dbf8f3ee3c50d811999a4a0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Oct 2017 17:11:21 +0200
Subject: [PATCH 3/5] torture: Remove GETADDRINFO test

This was the only user of getaddrinfo_send and not run anyway

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 selftest/skip             |  1 -
 source3/selftest/tests.py |  2 +-
 source3/torture/torture.c | 54 -----------------------------------------------
 3 files changed, 1 insertion(+), 56 deletions(-)

diff --git a/selftest/skip b/selftest/skip
index c2c4553c3fe..dd60ab5a1fb 100644
--- a/selftest/skip
+++ b/selftest/skip
@@ -145,4 +145,3 @@ bench # don't run benchmarks in our selftest
 ^samba4.blackbox.ktpass # this test isn't portable ...
 ^samba4.rpc.unixinfo # This contains a server-side getpwuid call which hangs the server when nss_winbindd is in use
 ^samba.tests.dcerpc.unix  # This contains a server-side getpwuid call which hangs the server when nss_winbindd is in use
-GETADDRINFO # socket wrapper doesn't support threads
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 8efc42c58d0..c1e08d56731 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -72,7 +72,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
         "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "WILDDELETE", "PROPERTIES", "W2K",
         "TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2", "OWNER-RIGHTS",
         "CHAIN3", "PIDHIGH",
-        "GETADDRINFO", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
+        "UID-REGRESSION-TEST", "SHORTNAME-TEST",
         "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT",
         "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE",
         "CLEANUP1",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index bb4908fd127..360adad5953 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -10863,59 +10863,6 @@ static bool run_wbclient_multi_ping(int dummy)
 	return result;
 }
 
-static void getaddrinfo_finished(struct tevent_req *req)
-{
-	char *name = (char *)tevent_req_callback_data_void(req);
-	struct addrinfo *ainfo;
-	int res;
-
-	res = getaddrinfo_recv(req, &ainfo);
-	if (res != 0) {
-		d_printf("gai(%s) returned %s\n", name, gai_strerror(res));
-		return;
-	}
-	d_printf("gai(%s) succeeded\n", name);
-	freeaddrinfo(ainfo);
-}
-
-static bool run_getaddrinfo_send(int dummy)
-{
-	TALLOC_CTX *frame = talloc_stackframe();
-	struct fncall_context *ctx;
-	struct tevent_context *ev;
-	bool result = false;
-	const char *names[4] = { "www.samba.org", "notfound.samba.org",
-				 "www.slashdot.org", "heise.de" };
-	struct tevent_req *reqs[4];
-	int i;
-
-	ev = samba_tevent_context_init(frame);
-	if (ev == NULL) {
-		goto fail;
-	}
-
-	ctx = fncall_context_init(frame, 4);
-
-	for (i=0; i<ARRAY_SIZE(names); i++) {
-		reqs[i] = getaddrinfo_send(frame, ev, ctx, names[i], NULL,
-					   NULL);
-		if (reqs[i] == NULL) {
-			goto fail;
-		}
-		tevent_req_set_callback(reqs[i], getaddrinfo_finished,
-					discard_const_p(void, names[i]));
-	}
-
-	for (i=0; i<ARRAY_SIZE(reqs); i++) {
-		tevent_loop_once(ev);
-	}
-
-	result = true;
-fail:
-	TALLOC_FREE(frame);
-	return result;
-}
-
 static bool dbtrans_inc(struct db_context *db)
 {
 	struct db_record *rec;
@@ -11576,7 +11523,6 @@ static struct {
 	{ "NTTRANS-CREATE", run_nttrans_create, 0},
 	{ "NTTRANS-FSCTL", run_nttrans_fsctl, 0},
 	{ "CLI_ECHO", run_cli_echo, 0},
-	{ "GETADDRINFO", run_getaddrinfo_send, 0},
 	{ "TLDAP", run_tldap },
 	{ "STREAMERROR", run_streamerror },
 	{ "NOTIFY-BENCH", run_notify_bench },
-- 
2.11.0


From 431bee384317c8ecb069a72f0deb71e9cbc1b0ba Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Oct 2017 17:13:04 +0200
Subject: [PATCH 4/5] lib: Remove unused getaddinfo_send/recv

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/proto.h |  7 -----
 source3/lib/util_sock.c | 82 -------------------------------------------------
 2 files changed, 89 deletions(-)

diff --git a/source3/include/proto.h b/source3/include/proto.h
index b2c3a03a193..1a27996a21b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -569,13 +569,6 @@ int create_pipe_sock(const char *socket_dir,
 int create_tcpip_socket(const struct sockaddr_storage *ifss, uint16_t *port);
 const char *get_mydnsfullname(void);
 bool is_myname_or_ipaddr(const char *s);
-struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
-				    struct tevent_context *ev,
-				    struct fncall_context *ctx,
-				    const char *node,
-				    const char *service,
-				    const struct addrinfo *hints);
-int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
 int poll_one_fd(int fd, int events, int timeout, int *revents);
 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
 
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 0e1a66c8273..c74fcd9138d 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1346,88 +1346,6 @@ bool is_myname_or_ipaddr(const char *s)
 	return false;
 }
 
-struct getaddrinfo_state {
-	const char *node;
-	const char *service;
-	const struct addrinfo *hints;
-	struct addrinfo *res;
-	int ret;
-};
-
-static void getaddrinfo_do(void *private_data);
-static void getaddrinfo_done(struct tevent_req *subreq);
-
-struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
-				    struct tevent_context *ev,
-				    struct fncall_context *ctx,
-				    const char *node,
-				    const char *service,
-				    const struct addrinfo *hints)
-{
-	struct tevent_req *req, *subreq;
-	struct getaddrinfo_state *state;
-
-	req = tevent_req_create(mem_ctx, &state, struct getaddrinfo_state);
-	if (req == NULL) {
-		return NULL;
-	}
-
-	state->node = node;
-	state->service = service;
-	state->hints = hints;
-
-	subreq = fncall_send(state, ev, ctx, getaddrinfo_do, state);
-	if (tevent_req_nomem(subreq, req)) {
-		return tevent_req_post(req, ev);
-	}
-	tevent_req_set_callback(subreq, getaddrinfo_done, req);
-	return req;
-}
-
-static void getaddrinfo_do(void *private_data)
-{
-	struct getaddrinfo_state *state =
-		talloc_get_type_abort(private_data, struct getaddrinfo_state);
-
-	state->ret = getaddrinfo(state->node, state->service, state->hints,
-				 &state->res);
-}
-
-static void getaddrinfo_done(struct tevent_req *subreq)
-{
-	struct tevent_req *req = tevent_req_callback_data(
-		subreq, struct tevent_req);
-	int ret, err;
-
-	ret = fncall_recv(subreq, &err);
-	TALLOC_FREE(subreq);
-	if (ret == -1) {
-		tevent_req_error(req, err);
-		return;
-	}
-	tevent_req_done(req);
-}
-
-int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res)
-{
-	struct getaddrinfo_state *state = tevent_req_data(
-		req, struct getaddrinfo_state);
-	int err;
-
-	if (tevent_req_is_unix_error(req, &err)) {
-		switch(err) {
-		case ENOMEM:
-			return EAI_MEMORY;
-		default:
-			return EAI_FAIL;
-		}
-	}
-	if (state->ret == 0) {
-		*res = state->res;
-	}
-	return state->ret;
-}
-
 int poll_one_fd(int fd, int events, int timeout, int *revents)
 {
 	struct pollfd pfd;
-- 
2.11.0


From fbb65bf7e8c02de7931bac5cc457257cff50d3c6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 18 Oct 2017 17:15:53 +0200
Subject: [PATCH 5/5] lib: Remove fncall.c

This was meant as a nice wrapper around pthreadpool_add_job.

pthreadpool_tevent_job_send does the same thing. The
getaddrinfo_send/recv was the only example and can easily be re-added on
top of pthreadpool_tevent_job_send.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/proto.h |  10 --
 source3/include/smb.h   |   1 -
 source3/lib/fncall.c    | 332 ------------------------------------------------
 source3/wscript_build   |   1 -
 4 files changed, 344 deletions(-)
 delete mode 100644 source3/lib/fncall.c

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1a27996a21b..c86cd44c4fc 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1024,16 +1024,6 @@ char *get_pass( const char *prompt, bool stdin_get);
 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
 				    struct tevent_context *ev);
 
-/* The following definitions come from lib/fncall.c */
-
-struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
-					   int max_threads);
-struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       struct fncall_context *ctx,
-			       void (*fn)(void *private_data),
-			       void *private_data);
-int fncall_recv(struct tevent_req *req, int *perr);
-
 /* The following definitions come from libsmb/smbsock_connect.c */
 
 struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 24a73e57a3d..0e79cb8d2e5 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -125,7 +125,6 @@ struct uuid;
 struct named_mutex;
 struct wb_context;
 struct rpc_cli_smbd_conn;
-struct fncall_context;
 
 /* the basic packet size, assuming no words or bytes */
 #define smb_size 39
diff --git a/source3/lib/fncall.c b/source3/lib/fncall.c
deleted file mode 100644
index 34db4725e89..00000000000
--- a/source3/lib/fncall.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Async fn calls
- * Copyright (C) Volker Lendecke 2009
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "includes.h"
-#include "../lib/util/tevent_unix.h"
-
-#include "../lib/pthreadpool/pthreadpool_pipe.h"
-
-struct fncall_state {
-	struct fncall_context *ctx;
-	int job_id;
-	bool done;
-
-	void *private_parent;
-	void *job_private;
-};
-
-struct fncall_context {
-	struct pthreadpool_pipe *pool;
-	int next_job_id;
-	int sig_fd;
-	struct tevent_req **pending;
-
-	struct fncall_state **orphaned;
-	int num_orphaned;
-
-	struct tevent_fd *fde;
-};
-
-static void fncall_handler(struct tevent_context *ev, struct tevent_fd *fde,
-			   uint16_t flags, void *private_data);
-
-static int fncall_context_destructor(struct fncall_context *ctx)
-{
-	while (talloc_array_length(ctx->pending) != 0) {
-		/* No TALLOC_FREE here */
-		talloc_free(ctx->pending[0]);
-	}
-
-	while (ctx->num_orphaned != 0) {
-		/*
-		 * We've got jobs in the queue for which the tevent_req has
-		 * been finished already. Wait for all of them to finish.
-		 */
-		fncall_handler(NULL, NULL, TEVENT_FD_READ, ctx);
-	}
-
-	pthreadpool_pipe_destroy(ctx->pool);
-	ctx->pool = NULL;
-
-	return 0;
-}
-
-struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
-					   int max_threads)
-{
-	struct fncall_context *ctx;
-	int ret;
-
-	ctx = talloc_zero(mem_ctx, struct fncall_context);
-	if (ctx == NULL) {
-		return NULL;
-	}
-
-	ret = pthreadpool_pipe_init(max_threads, &ctx->pool);
-	if (ret != 0) {
-		TALLOC_FREE(ctx);
-		return NULL;
-	}
-	talloc_set_destructor(ctx, fncall_context_destructor);
-
-	ctx->sig_fd = pthreadpool_pipe_signal_fd(ctx->pool);
-	if (ctx->sig_fd == -1) {
-		TALLOC_FREE(ctx);
-		return NULL;
-	}
-
-	return ctx;
-}
-
-static int fncall_next_job_id(struct fncall_context *ctx)
-{
-	int num_pending = talloc_array_length(ctx->pending);
-	int result;
-
-	while (true) {
-		int i;
-
-		result = ctx->next_job_id++;
-		if (result == 0) {
-			continue;
-		}
-
-		for (i=0; i<num_pending; i++) {
-			struct fncall_state *state = tevent_req_data(
-				ctx->pending[i], struct fncall_state);
-
-			if (result == state->job_id) {
-				break;
-			}
-		}
-		if (i == num_pending) {
-			return result;
-		}
-	}
-}
-
-static void fncall_unset_pending(struct tevent_req *req);
-static void fncall_cleanup(struct tevent_req *req,
-			   enum tevent_req_state req_state);
-
-static bool fncall_set_pending(struct tevent_req *req,
-			       struct fncall_context *ctx,
-			       struct tevent_context *ev)
-{
-	struct tevent_req **pending;
-	int num_pending, orphaned_array_length;
-
-	num_pending = talloc_array_length(ctx->pending);
-
-	pending = talloc_realloc(ctx, ctx->pending, struct tevent_req *,
-				 num_pending+1);
-	if (pending == NULL) {
-		return false;
-	}
-	pending[num_pending] = req;
-	num_pending += 1;
-	ctx->pending = pending;
-	tevent_req_set_cleanup_fn(req, fncall_cleanup);
-
-	/*
-	 * Make sure that the orphaned array of fncall_state structs has
-	 * enough space. A job can change from pending to orphaned in
-	 * fncall_cleanup, and to fail in a talloc destructor should be
-	 * avoided if possible.
-	 */
-
-	orphaned_array_length = talloc_array_length(ctx->orphaned);
-	if (num_pending > orphaned_array_length) {
-		struct fncall_state **orphaned;
-
-		orphaned = talloc_realloc(ctx, ctx->orphaned,
-					  struct fncall_state *,
-					  orphaned_array_length + 1);
-		if (orphaned == NULL) {
-			fncall_unset_pending(req);
-			return false;
-		}
-		ctx->orphaned = orphaned;
-	}
-
-	if (ctx->fde != NULL) {
-		return true;
-	}
-
-	ctx->fde = tevent_add_fd(ev, ctx->pending, ctx->sig_fd, TEVENT_FD_READ,
-				 fncall_handler, ctx);
-	if (ctx->fde == NULL) {
-		fncall_unset_pending(req);
-		return false;
-	}
-	return true;
-}
-
-static void fncall_unset_pending(struct tevent_req *req)
-{
-	struct fncall_state *state = tevent_req_data(req, struct fncall_state);
-	struct fncall_context *ctx = state->ctx;
-	int num_pending = talloc_array_length(ctx->pending);
-	int i;
-
-	tevent_req_set_cleanup_fn(req, NULL);
-
-	if (num_pending == 1) {
-		TALLOC_FREE(ctx->fde);
-		TALLOC_FREE(ctx->pending);
-		return;
-	}
-
-	for (i=0; i<num_pending; i++) {
-		if (req == ctx->pending[i]) {
-			break;
-		}
-	}
-	if (i == num_pending) {
-		return;
-	}
-	if (num_pending > 1) {
-		ctx->pending[i] = ctx->pending[num_pending-1];
-	}
-	ctx->pending = talloc_realloc(NULL, ctx->pending, struct tevent_req *,
-				      num_pending - 1);
-}
-
-static void fncall_cleanup(struct tevent_req *req,
-			   enum tevent_req_state req_state)
-{
-	struct fncall_state *state = tevent_req_data(
-		req, struct fncall_state);
-	struct fncall_context *ctx = state->ctx;
-
-	switch (req_state) {
-	case TEVENT_REQ_RECEIVED:
-		break;
-	default:
-		return;
-	}
-
-	fncall_unset_pending(req);
-
-	if (state->done) {
-		return;
-	}
-
-	/*
-	 * Keep around the state of the deleted request until the request has
-	 * finished in the helper thread. fncall_handler will destroy it.
-	 */
-	ctx->orphaned[ctx->num_orphaned] = talloc_move(ctx->orphaned, &state);
-	ctx->num_orphaned += 1;
-}
-
-struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       struct fncall_context *ctx,
-			       void (*fn)(void *private_data),
-			       void *private_data)
-{
-	struct tevent_req *req;
-	struct fncall_state *state;
-	int ret;
-
-	req = tevent_req_create(mem_ctx, &state, struct fncall_state);
-	if (req == NULL) {
-		return NULL;
-	}
-	state->ctx = ctx;
-	state->job_id = fncall_next_job_id(state->ctx);
-	state->done = false;
-
-	/*
-	 * We need to keep the private data we handed out to the thread around
-	 * as long as the job is not finished. This is a bit of an abstraction
-	 * violation, because the "req->state1->subreq->state2" (we're
-	 * "subreq", "req" is the request our caller creates) is broken to
-	 * "ctx->state2->state1", but we are right now in the destructor for
-	 * "subreq2", so what can we do. We need to keep state1 around,
-	 * otherwise the helper thread will have no place to put its results.
-	 */
-
-	state->private_parent = talloc_parent(private_data);
-	state->job_private = talloc_move(state, &private_data);
-
-	ret = pthreadpool_pipe_add_job(state->ctx->pool, state->job_id, fn,
-				       state->job_private);
-	if (ret == -1) {
-		tevent_req_error(req, errno);
-		return tevent_req_post(req, ev);
-	}
-	if (!fncall_set_pending(req, state->ctx, ev)) {
-		tevent_req_oom(req);
-		return tevent_req_post(req, ev);
-	}
-	return req;
-}
-
-static void fncall_handler(struct tevent_context *ev, struct tevent_fd *fde,
-			   uint16_t flags, void *private_data)
-{
-	struct fncall_context *ctx = talloc_get_type_abort(
-		private_data, struct fncall_context);
-	int i, num_pending;
-	int job_id;
-
-	if (pthreadpool_pipe_finished_jobs(ctx->pool, &job_id, 1) < 0) {
-		return;
-	}
-
-	num_pending = talloc_array_length(ctx->pending);
-
-	for (i=0; i<num_pending; i++) {
-		struct fncall_state *state = tevent_req_data(
-			ctx->pending[i], struct fncall_state);
-
-		if (job_id == state->job_id) {
-			state->done = true;
-			talloc_move(state->private_parent,
-				    &state->job_private);
-			tevent_req_done(ctx->pending[i]);
-			return;
-		}
-	}
-
-	for (i=0; i<ctx->num_orphaned; i++) {
-		if (job_id == ctx->orphaned[i]->job_id) {
-			break;
-		}
-	}
-	if (i == ctx->num_orphaned) {
-		return;
-	}
-
-	TALLOC_FREE(ctx->orphaned[i]);
-
-	if (i < ctx->num_orphaned-1) {
-		ctx->orphaned[i] = ctx->orphaned[ctx->num_orphaned-1];
-	}
-	ctx->num_orphaned -= 1;
-}
-
-int fncall_recv(struct tevent_req *req, int *perr)
-{
-	if (tevent_req_is_unix_error(req, perr)) {
-		return -1;
-	}
-	return 0;
-}
diff --git a/source3/wscript_build b/source3/wscript_build
index be0811f8737..dc7a51cc97a 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -404,7 +404,6 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                           lib/server_prefork.c
                           lib/server_prefork_util.c
                           lib/ldap_escape.c
-                          lib/fncall.c
                           libads/krb5_errs.c
                           lib/system_smbd.c
                           lib/audit.c
-- 
2.11.0



More information about the samba-technical mailing list