summaryrefslogtreecommitdiff
path: root/sys/rpc
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2017-02-14 17:49:08 +0000
committerAndriy Gapon <avg@FreeBSD.org>2017-02-14 17:49:08 +0000
commit90f90687b3c354a3530e251e6a9192b404b379ae (patch)
treec96cd0da9b67e10989d2c0a963ffc627163b143e /sys/rpc
parenta3f89e36ec689ea7d784b3c7ab6fba71ffee159a (diff)
downloadsrc-test2-90f90687b3c354a3530e251e6a9192b404b379ae.tar.gz
src-test2-90f90687b3c354a3530e251e6a9192b404b379ae.zip
Notes
Diffstat (limited to 'sys/rpc')
-rw-r--r--sys/rpc/svc.c42
-rw-r--r--sys/rpc/svc.h6
2 files changed, 46 insertions, 2 deletions
diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index ea0024bc0b11..5e5552dfe313 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -75,6 +75,7 @@ static void svc_new_thread(SVCGROUP *grp);
static void xprt_unregister_locked(SVCXPRT *xprt);
static void svc_change_space_used(SVCPOOL *pool, long delta);
static bool_t svc_request_space_available(SVCPOOL *pool);
+static void svcpool_cleanup(SVCPOOL *pool);
/* *************** SVCXPRT related stuff **************** */
@@ -174,8 +175,12 @@ svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base)
return pool;
}
-void
-svcpool_destroy(SVCPOOL *pool)
+/*
+ * Code common to svcpool_destroy() and svcpool_close(), which cleans up
+ * the pool data structures.
+ */
+static void
+svcpool_cleanup(SVCPOOL *pool)
{
SVCGROUP *grp;
SVCXPRT *xprt, *nxprt;
@@ -211,6 +216,15 @@ svcpool_destroy(SVCPOOL *pool)
mtx_lock(&pool->sp_lock);
}
mtx_unlock(&pool->sp_lock);
+}
+
+void
+svcpool_destroy(SVCPOOL *pool)
+{
+ SVCGROUP *grp;
+ int g;
+
+ svcpool_cleanup(pool);
for (g = 0; g < SVC_MAXGROUPS; g++) {
grp = &pool->sp_groups[g];
@@ -226,6 +240,30 @@ svcpool_destroy(SVCPOOL *pool)
}
/*
+ * Similar to svcpool_destroy(), except that it does not destroy the actual
+ * data structures. As such, "pool" may be used again.
+ */
+void
+svcpool_close(SVCPOOL *pool)
+{
+ SVCGROUP *grp;
+ int g;
+
+ svcpool_cleanup(pool);
+
+ /* Now, initialize the pool's state for a fresh svc_run() call. */
+ mtx_lock(&pool->sp_lock);
+ pool->sp_state = SVCPOOL_INIT;
+ mtx_unlock(&pool->sp_lock);
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ grp->sg_state = SVCPOOL_ACTIVE;
+ mtx_unlock(&grp->sg_lock);
+ }
+}
+
+/*
* Sysctl handler to get the present thread count on a pool
*/
static int
diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h
index 22322ba68448..dacf5d1a8992 100644
--- a/sys/rpc/svc.h
+++ b/sys/rpc/svc.h
@@ -729,6 +729,12 @@ extern SVCPOOL* svcpool_create(const char *name,
extern void svcpool_destroy(SVCPOOL *pool);
/*
+ * Close a service pool. Similar to svcpool_destroy(), but it does not
+ * free the data structures. As such, the pool can be used again.
+ */
+extern void svcpool_close(SVCPOOL *pool);
+
+/*
* Transport independent svc_create routine.
*/
extern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),