summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2017-10-19 11:49:42 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-11-06 16:46:33 +0000
commit6707eddaa5d7fdce16d39c19963911868a2c7fee (patch)
tree42bfa718a33a13007d967e4a70242afc7f986c1b /rpc/rpc-lib
parented5e7b48f9255a57e0a691c102a207eb2445e8b7 (diff)
rpc: optimize fop program lookup
Ensure that the fop program is the first in the program list so that there's minimum amount of time spent to search the program for the most frequently needed use case. Change-Id: I45c3dcdbf39ec90ba39d914432d13a2ace00a5ee BUG: 1509647 Signed-off-by: Milind Changire <mchangir@redhat.com>
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c10
-rw-r--r--rpc/rpc-lib/src/rpcsvc.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index d62abde47c5..ffc6b763590 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -1995,7 +1995,8 @@ rpcsvc_request_handler (void *arg)
}
int
-rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program)
+rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program,
+ gf_boolean_t add_to_head)
{
int ret = -1;
rpcsvc_program_t *newprog = NULL;
@@ -2052,7 +2053,10 @@ rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program)
pthread_rwlock_wrlock (&svc->rpclock);
{
- list_add_tail (&newprog->program, &svc->programs);
+ if (add_to_head)
+ list_add (&newprog->program, &svc->programs);
+ else
+ list_add_tail (&newprog->program, &svc->programs);
}
pthread_rwlock_unlock (&svc->rpclock);
@@ -2513,7 +2517,7 @@ rpcsvc_init (xlator_t *xl, glusterfs_ctx_t *ctx, dict_t *options,
gluster_dump_prog.options = options;
- ret = rpcsvc_program_register (svc, &gluster_dump_prog);
+ ret = rpcsvc_program_register (svc, &gluster_dump_prog, _gf_false);
if (ret) {
gf_log (GF_RPCSVC, GF_LOG_ERROR,
"failed to register DUMP program");
diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h
index 37244be5361..1fdbc69c7ad 100644
--- a/rpc/rpc-lib/src/rpcsvc.h
+++ b/rpc/rpc-lib/src/rpcsvc.h
@@ -423,7 +423,8 @@ typedef struct rpcsvc_cbk_program {
* procedure handlers.
*/
extern int
-rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program);
+rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program,
+ gf_boolean_t add_to_head);
extern int
rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t *program);