summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src/rpcsvc.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-08-20 10:19:15 -0700
committerAnand Avati <avati@redhat.com>2012-09-19 23:18:08 -0700
commit38afd84faa383c5e0be21c48c918112b7b01a5cf (patch)
treed43a43445165ac2005fe4424f7b8fb2bd15d979a /rpc/rpc-lib/src/rpcsvc.c
parenta3c5722b39895f5fa4721cfae456e26bc758b33a (diff)
rpcsvc: framework for executing actors as synctask
An rpcsvc_program can be registered by setting .synctask field to 1 which will make actors of that program be executed in a synctask, thus freeing up the rpc/poll thread while the actor executes. Change-Id: Idacef2ad3bcae0f354fd0fc16ca06ba7094d7b98 BUG: 762935 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/3833 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'rpc/rpc-lib/src/rpcsvc.c')
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index ca637a50617..ad1e4f47888 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -27,6 +27,7 @@
#include "xdr-common.h"
#include "xdr-generic.h"
#include "rpc-common-xdr.h"
+#include "syncop.h"
#include <errno.h>
#include <pthread.h>
@@ -206,6 +207,8 @@ rpcsvc_program_actor (rpcsvc_request_t *req)
goto err;
}
+ req->synctask = program->synctask;
+
err = SUCCESS;
gf_log (GF_RPCSVC, GF_LOG_TRACE, "Actor found: %s - %s",
program->progname, actor->procname);
@@ -431,6 +434,20 @@ err:
int
+rpcsvc_synctask_cbk (int ret, call_frame_t *frame, void *opaque)
+{
+ rpcsvc_request_t *req = NULL;
+
+ req = opaque;
+
+ if (ret == RPCSVC_ACTOR_ERROR)
+ rpcsvc_error_reply (req);
+
+ return 0;
+}
+
+
+int
rpcsvc_handle_rpc_call (rpcsvc_t *svc, rpc_transport_t *trans,
rpc_transport_pollin_t *msg)
{
@@ -510,7 +527,12 @@ rpcsvc_handle_rpc_call (rpcsvc_t *svc, rpc_transport_t *trans,
goto err_reply;
}
- ret = actor_fn (req);
+ if (req->synctask)
+ ret = synctask_new (THIS->ctx->env,
+ (synctask_fn_t) actor_fn,
+ rpcsvc_synctask_cbk, NULL, req);
+ else
+ ret = actor_fn (req);
}
err_reply: