summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorAnand V. Avati <avati@blackhole.gluster.com>2010-08-12 05:05:02 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-12 03:55:16 -0700
commit12ce6a962aee3674eb722a09241b43923712ee8e (patch)
tree61b9e822a8dc398e24c654378fcfd886ce51c447 /rpc/rpc-lib
parentb69a4f1e31726260a07f883cefac28ed29cc6a12 (diff)
rpc-clnt/socket: rpc_clnt_reconfig() API to support overriding of port numbers
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1314 (portmapper functionality) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1314
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c22
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.h41
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c4
-rw-r--r--rpc/rpc-lib/src/rpc-transport.h4
4 files changed, 47 insertions, 24 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index dd28c60e0..7e3d90bfe 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -379,7 +379,7 @@ rpc_clnt_reconnect (void *trans_ptr)
gf_log (trans->name, GF_LOG_TRACE,
"attempting reconnect");
- ret = rpc_transport_connect (trans);
+ ret = rpc_transport_connect (trans, conn->config.remote_port);
conn->reconnect =
gf_timer_call_after (clnt->ctx, tv,
@@ -1261,7 +1261,8 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
pthread_mutex_lock (&conn->lock);
{
if (conn->connected == 0) {
- rpc_transport_connect (conn->trans);
+ rpc_transport_connect (conn->trans,
+ conn->config.remote_port);
}
ret = -1;
@@ -1348,3 +1349,20 @@ rpc_clnt_destroy (struct rpc_clnt *rpc)
GF_FREE (rpc);
return;
}
+
+
+void
+rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config)
+{
+ if (config->rpc_timeout)
+ rpc->conn.config.rpc_timeout = config->rpc_timeout;
+
+ if (config->remote_port)
+ rpc->conn.config.remote_port = config->remote_port;
+
+ if (config->remote_host) {
+ if (rpc->conn.config.remote_host)
+ FREE (rpc->conn.config.remote_host);
+ rpc->conn.config.remote_host = gf_strdup (config->remote_host);
+ }
+}
diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h
index b9d39b332..0e7dfa396 100644
--- a/rpc/rpc-lib/src/rpc-clnt.h
+++ b/rpc/rpc-lib/src/rpc-clnt.h
@@ -90,21 +90,30 @@ typedef struct rpc_auth_data {
char authdata[RPC_MAX_AUTH_BYTES];
} rpc_auth_data_t;
+
+struct rpc_clnt_config {
+ int rpc_timeout;
+ int remote_port;
+ char * remote_host;
+};
+
+
#define rpc_auth_flavour(au) ((au).flavour)
struct rpc_clnt_connection {
- pthread_mutex_t lock;
- rpc_transport_t *trans;
- gf_timer_t *reconnect;
- gf_timer_t *timer;
- gf_timer_t *ping_timer;
- struct rpc_clnt *rpc_clnt;
- char connected;
- struct saved_frames *saved_frames;
- int32_t frame_timeout;
- struct timeval last_sent;
- struct timeval last_received;
- int32_t ping_started;
+ pthread_mutex_t lock;
+ rpc_transport_t *trans;
+ struct rpc_clnt_config config;
+ gf_timer_t *reconnect;
+ gf_timer_t *timer;
+ gf_timer_t *ping_timer;
+ struct rpc_clnt *rpc_clnt;
+ char connected;
+ struct saved_frames *saved_frames;
+ int32_t frame_timeout;
+ struct timeval last_sent;
+ struct timeval last_received;
+ int32_t ping_started;
};
typedef struct rpc_clnt_connection rpc_clnt_connection_t;
@@ -140,12 +149,6 @@ struct rpc_clnt {
glusterfs_ctx_t *ctx;
};
-struct rpc_clnt_config {
- int rpc_timeout;
- int remote_port;
- char * remote_host;
-};
-
struct rpc_clnt * rpc_clnt_init (struct rpc_clnt_config *config,
dict_t *options, glusterfs_ctx_t *ctx,
@@ -185,4 +188,6 @@ void rpc_clnt_unset_connected (rpc_clnt_connection_t *conn);
void rpc_clnt_reconnect (void *trans_ptr);
+void rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config);
+
#endif /* !_RPC_CLNT_H */
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index c21d5ecfc..f3a979810 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -1010,13 +1010,13 @@ fail:
int32_t
-rpc_transport_connect (rpc_transport_t *this)
+rpc_transport_connect (rpc_transport_t *this, int port)
{
int ret = -1;
GF_VALIDATE_OR_GOTO("rpc_transport", this, fail);
- ret = this->ops->connect (this);
+ ret = this->ops->connect (this, port);
fail:
return ret;
}
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h
index 14ec8bc57..50ebe52a2 100644
--- a/rpc/rpc-lib/src/rpc-transport.h
+++ b/rpc/rpc-lib/src/rpc-transport.h
@@ -196,7 +196,7 @@ struct rpc_transport_ops {
rpc_transport_req_t *req);
int32_t (*submit_reply) (rpc_transport_t *this,
rpc_transport_reply_t *reply);
- int32_t (*connect) (rpc_transport_t *this);
+ int32_t (*connect) (rpc_transport_t *this, int port);
int32_t (*listen) (rpc_transport_t *this);
int32_t (*disconnect) (rpc_transport_t *this);
int32_t (*get_peername) (rpc_transport_t *this, char *hostname,
@@ -216,7 +216,7 @@ int32_t
rpc_transport_listen (rpc_transport_t *this);
int32_t
-rpc_transport_connect (rpc_transport_t *this);
+rpc_transport_connect (rpc_transport_t *this, int port);
int32_t
rpc_transport_disconnect (rpc_transport_t *this);