diff options
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 10 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.h | 11 | ||||
-rw-r--r-- | rpc/rpc-transport/socket/src/socket.c | 61 |
3 files changed, 80 insertions, 2 deletions
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index 43b2a0c18cf..2a10a3b7f80 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -804,6 +804,8 @@ err: return NULL; } + + rpc_transport_t * rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) { @@ -830,7 +832,7 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) type = str; /* Backward compatibility */ - ret = dict_get_str (options, "transport-type", &type); + ret = dict_get_str (options, "transport-type", &type); if (ret < 0) { ret = dict_set_str (options, "transport-type", "socket"); if (ret < 0) @@ -922,6 +924,12 @@ rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *trans_name) "dlsym (gf_rpc_transport_fini) on %s", dlerror ()); goto fail; } + + trans->reconfigure = dlsym (handle, "reconfigure"); + if (trans->fini == NULL) { + gf_log ("rpc-transport", GF_LOG_DEBUG, + "dlsym (gf_rpc_transport_reconfigure) on %s", dlerror()); + } vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), gf_common_mt_volume_opt_list_t); diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index 478de9ef1c4..560eae45314 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -25,6 +25,7 @@ #include "config.h" #endif + #include <inttypes.h> #ifdef GF_SOLARIS_HOST_OS #include <rpc/auth.h> @@ -34,6 +35,7 @@ #include <rpc/rpc_msg.h> + #ifndef MAX_IOVEC #define MAX_IOVEC 16 #endif @@ -172,6 +174,8 @@ typedef struct rpc_transport_pollin rpc_transport_pollin_t; typedef int (*rpc_transport_notify_t) (rpc_transport_t *, void *mydata, rpc_transport_event_t, void *data, ...); + + struct rpc_transport { struct rpc_transport_ops *ops; rpc_transport_t *listener; /* listener transport to which @@ -179,6 +183,7 @@ struct rpc_transport { * transport came from. valid only * on server process. */ + void *private; void *xl_private; void *xl; /* Used for THIS */ @@ -191,8 +196,12 @@ struct rpc_transport { char *name; void *dnscache; data_t *buf; - int32_t (*init) (rpc_transport_t *this); + int32_t (*init) (rpc_transport_t *this); void (*fini) (rpc_transport_t *this); + int32_t (*validate_options) (rpc_transport_t *this, + dict_t *options, + char **op_errstr); + int (*reconfigure) (rpc_transport_t *this, dict_t *options); rpc_transport_notify_t notify; void *notify_data; peer_info_t peerinfo; diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 40531ad4c2a..c5246822a7c 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -2422,6 +2422,67 @@ struct rpc_transport_ops tops = { .get_myaddr = socket_getmyaddr, }; +int +validate_options (rpc_transport_t *this, dict_t *options, char **op_errstr) +{ + char *optstr = NULL; + int ret = -1; + gf_boolean_t tmp_bool = _gf_false; + + if (dict_get_str (options, "transport.socket.keepalive", + &optstr) == 0) { + if (gf_string2boolean (optstr, &tmp_bool) == -1) { + gf_log (this->name, GF_LOG_ERROR, + "'transport.socket.keepalive' takes only " + "boolean options, not taking any action"); + *op_errstr = "Value should be only boolean!!"; + ret =-1; + goto out; + } + } + + ret =0; +out: + return ret; + +} + +int +reconfigure (rpc_transport_t *this, dict_t *options) +{ + socket_private_t *priv = NULL; + gf_boolean_t tmp_bool = _gf_false; + char *optstr = NULL; + int ret = -1; + + if (!this || !this->private) { + ret =-1; + goto out; + } + + + priv = this->private; + + if (dict_get_str (this->options, "transport.socket.keepalive", + &optstr) == 0) { + if (gf_string2boolean (optstr, &tmp_bool) == -1) { + gf_log (this->name, GF_LOG_ERROR, + "'transport.socket.keepalive' takes only " + "boolean options, not taking any action"); + priv->keepalive = 1; + goto out; + } + gf_log (this->name, GF_LOG_DEBUG, "Reconfigured transport.socket.keepalive"); + + priv->keepalive = tmp_bool; + } + else + priv->keepalive = 1; + ret = 0; +out: + return ret; + +} int socket_init (rpc_transport_t *this) |