summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-08-19 10:42:33 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-19 09:50:32 -0700
commita5dac1f49eb247d854348fe8ec54c33e664adf30 (patch)
treeb2973e967fa44feba7b1eabb813f0e51e1e4b988 /xlators/protocol/server/src/server.c
parent01c00dd2e1d3113acb3f20c5dc7c20fa8d286339 (diff)
rpcsvc: decouple creation of listener from rpcsvc_program_register and rpcsvc_init.
- with this patch every program that wants to register itself with rpcsvc should also create one or more listener(s) and register with portmap (if necessary). Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
Diffstat (limited to 'xlators/protocol/server/src/server.c')
-rw-r--r--xlators/protocol/server/src/server.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 96bb72901a7..7ab3de51c18 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -426,8 +426,9 @@ mem_acct_init (xlator_t *this)
int
init (xlator_t *this)
{
- int32_t ret = -1;
- server_conf_t *conf = NULL;
+ int32_t ret = -1;
+ server_conf_t *conf = NULL;
+ rpcsvc_listener_t *listener = NULL;
if (!this)
goto out;
@@ -476,24 +477,49 @@ init (xlator_t *this)
/* RPC related */
//conf->rpc = rpc_svc_init (&conf->rpc_conf);
conf->rpc = rpcsvc_init (this->ctx, this->options);
- if (!conf->rpc) {
+ if (conf->rpc == NULL) {
+ ret = -1;
+ goto out;
+ }
+
+ listener = rpcsvc_create_listener (conf->rpc, this->options,
+ this->name);
+ if (listener == NULL) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "creation of listener failed");
ret = -1;
goto out;
}
ret = rpcsvc_register_notify (conf->rpc, server_rpc_notify, this);
- if (ret)
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "registration of notify with rpcsvc failed");
goto out;
+ }
glusterfs3_1_fop_prog.options = this->options;
- ret = rpcsvc_program_register (conf->rpc, glusterfs3_1_fop_prog);
- if (ret)
+ ret = rpcsvc_program_register (conf->rpc, &glusterfs3_1_fop_prog);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "registration of program (name:%s, prognum:%d, "
+ "progver:%d) failed", glusterfs3_1_fop_prog.progname,
+ glusterfs3_1_fop_prog.prognum,
+ glusterfs3_1_fop_prog.progver);
goto out;
+ }
gluster_handshake_prog.options = this->options;
- ret = rpcsvc_program_register (conf->rpc, gluster_handshake_prog);
- if (ret)
+ ret = rpcsvc_program_register (conf->rpc, &gluster_handshake_prog);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "registration of program (name:%s, prognum:%d, "
+ "progver:%d) failed", gluster_handshake_prog.progname,
+ gluster_handshake_prog.prognum,
+ gluster_handshake_prog.progver);
+ rpcsvc_program_unregister (conf->rpc, &glusterfs3_1_fop_prog);
goto out;
+ }
#ifndef GF_DARWIN_HOST_OS
{
@@ -523,8 +549,15 @@ init (xlator_t *this)
ret = 0;
out:
- if (ret && this)
- this->fini (this);
+ if (ret) {
+ if (this != NULL) {
+ this->fini (this);
+ }
+
+ if (listener != NULL) {
+ rpcsvc_listener_destroy (listener);
+ }
+ }
return ret;
}