diff options
author | Amar Tumballi <amar@gluster.com> | 2010-06-23 02:55:21 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-06-24 10:32:11 -0700 |
commit | e82ca8fc5164f4ba2ff396da86b4a490d9a47370 (patch) | |
tree | 1c92b4d4c0a4ad42b2213f17c92ededc45ae89a2 /xlators/protocol/rpc/rpc-lib/src | |
parent | 487e9f1d59bbf7b37a30ceef5dbfd8ca77b94988 (diff) |
minor improvements in protocol
* rpc_clnt_submit() now takes 'cbkfn' as an argument.
* readdir xdr now uses dirent structure directly instead of
using 'opaque' buffer through which it was serializing /
unserializing the dirent structure.
* 'gfs_id' field (currently used for debugging) is properly updated
Signed-off-by: Amar Tumballi <amar@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/rpc/rpc-lib/src')
-rw-r--r-- | xlators/protocol/rpc/rpc-lib/src/rpc-clnt.c | 42 | ||||
-rw-r--r-- | xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h | 20 | ||||
-rw-r--r-- | xlators/protocol/rpc/rpc-lib/src/rpcsvc.c | 1 |
3 files changed, 28 insertions, 35 deletions
diff --git a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.c b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.c index 92f57e521..da02b9f42 100644 --- a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.c +++ b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.c @@ -63,8 +63,8 @@ __saved_frames_get_timedout (struct saved_frames *frames, uint32_t timeout, struct saved_frame * -__saved_frames_put (struct saved_frames *frames, void *frame, - int32_t procnum, rpc_clnt_prog_t *prog, int64_t callid) +__saved_frames_put (struct saved_frames *frames, void *frame, int32_t procnum, + rpc_clnt_prog_t *prog, fop_cbk_fn_t cbk, int64_t callid) { struct saved_frame *saved_frame = NULL; @@ -82,6 +82,7 @@ __saved_frames_put (struct saved_frames *frames, void *frame, saved_frame->procnum = procnum; saved_frame->callid = callid; saved_frame->prog = prog; + saved_frame->cbkfn = cbk; gettimeofday (&saved_frame->saved_at, NULL); @@ -179,14 +180,14 @@ call_bail (void *data) strftime (frame_sent, 32, "%Y-%m-%d %H:%M:%S", &frame_sent_tm); gf_log (conn->trans->name, GF_LOG_ERROR, - "bailing out frame type(%s) op(%s) frame sent = %s. " - "frame-timeout = %d", - trav->prog->progname, - trav->prog->actor[trav->procnum].procname, frame_sent, + "bailing out frame type(%s) op(%s(%d)) sent = %s. " + "timeout = %d", + trav->prog->progname, (trav->prog->procnames) ? + trav->prog->procnames[trav->procnum] : "--", + trav->procnum, frame_sent, conn->frame_timeout); - trav->prog->actor [trav->procnum].cbkfn (&req, &iov, 1, - trav->frame); + trav->cbkfn (&req, &iov, 1, trav->frame); list_del_init (&trav->list); GF_FREE (trav); @@ -199,7 +200,7 @@ out: /* to be called with conn->lock held */ struct saved_frame * __save_frame (struct rpc_clnt *rpc_clnt, call_frame_t *frame, int procnum, - rpc_clnt_prog_t *prog, uint64_t callid) + rpc_clnt_prog_t *prog, fop_cbk_fn_t cbk, uint64_t callid) { rpc_clnt_connection_t *conn = NULL; struct timeval timeout = {0, }; @@ -208,7 +209,7 @@ __save_frame (struct rpc_clnt *rpc_clnt, call_frame_t *frame, int procnum, conn = &rpc_clnt->conn; saved_frame = __saved_frames_put (conn->saved_frames, frame, - procnum, prog, callid); + procnum, prog, cbk, callid); if (saved_frame == NULL) { goto out; } @@ -307,14 +308,14 @@ saved_frames_unwind (struct saved_frames *saved_frames) list_for_each_entry_safe (trav, tmp, &saved_frames->sf.list, list) { gf_log ("rpc-clnt", GF_LOG_ERROR, - "forced unwinding frame type(%s) op(%s)", - trav->prog->progname, - trav->prog->actor [trav->procnum].procname); + "forced unwinding frame type(%s) op(%s(%d))", + trav->prog->progname, (trav->prog->procnames) ? + trav->prog->procnames[trav->procnum] : "--", + trav->procnum); saved_frames->count--; - trav->prog->actor [trav->procnum].cbkfn (&req, &iov, 1, - trav->frame); + trav->cbkfn (&req, &iov, 1, trav->frame); list_del_init (&trav->list); GF_FREE (trav); @@ -655,9 +656,7 @@ rpc_clnt_handle_reply (struct rpc_clnt *clnt, rpc_transport_pollin_t *pollin) "failed"); } - saved_frame->prog->actor [request_info->procnum].cbkfn (&req, req.rsp, - req.rspcnt, - saved_frame->frame); + saved_frame->cbkfn (&req, req.rsp, req.rspcnt, saved_frame->frame); if (ret == 0) { rpc_clnt_reply_deinit (&req); @@ -1155,7 +1154,8 @@ out: int -rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum, +rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, + int procnum, fop_cbk_fn_t cbkfn, struct iovec *proghdr, int proghdrcount, struct iovec *progpayload, int progpayloadcount, struct iobref *iobref, void *frame) @@ -1242,7 +1242,7 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum, if ((ret >= 0) && frame) { gettimeofday (&conn->last_sent, NULL); /* Save the frame in queue */ - __save_frame (rpc, frame, procnum, prog, callid); + __save_frame (rpc, frame, procnum, prog, cbkfn, callid); } } @@ -1264,7 +1264,7 @@ out: if (frame && (ret == -1)) { rpcreq.rpc_status = -1; - prog->actor [procnum].cbkfn (&rpcreq, NULL, 0, frame); + cbkfn (&rpcreq, NULL, 0, frame); } return ret; } diff --git a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h index 89942ce7f..efc256cd2 100644 --- a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h +++ b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h @@ -45,8 +45,7 @@ typedef int (*rpc_clnt_notify_t) (struct rpc_clnt *rpc, void *mydata, typedef int (*fop_cbk_fn_t) (struct rpc_req *req, struct iovec *iov, int count, void *myframe); -typedef int (*clnt_fn_t) (call_frame_t *, xlator_t *, - struct rpc_clnt_program *, void *args); +typedef int (*clnt_fn_t) (call_frame_t *fr, xlator_t *xl, void *args); struct saved_frame { union { @@ -61,37 +60,29 @@ struct saved_frame { struct timeval saved_at; int32_t procnum; struct rpc_clnt_program *prog; + fop_cbk_fn_t cbkfn; uint64_t callid; rpc_transport_rsp_t rsp; }; - struct saved_frames { int64_t count; struct saved_frame sf; }; -/* TODO: */ -struct xptr_clnt { - int remote_port; - char * remote_host; - - /* xptr specific */ - peer_info_t peerinfo; -}; /* Initialized by procnum */ typedef struct rpc_clnt_procedure { char *procname; clnt_fn_t fn; - fop_cbk_fn_t cbkfn; } rpc_clnt_procedure_t; typedef struct rpc_clnt_program { char *progname; int prognum; int progver; - rpc_clnt_procedure_t *actor; + rpc_clnt_procedure_t *proctable; + char **procnames; int numproc; } rpc_clnt_prog_t; @@ -158,7 +149,8 @@ struct rpc_clnt * rpc_clnt_init (struct rpc_clnt_config *config, int rpc_clnt_register_notify (struct rpc_clnt *rpc, rpc_clnt_notify_t fn, void *mydata); -int rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum, +int rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, + int procnum, fop_cbk_fn_t cbkfn, struct iovec *proghdr, int proghdrcount, struct iovec *progpayload, int progpayloadcount, struct iobref *iobref, void *frame); diff --git a/xlators/protocol/rpc/rpc-lib/src/rpcsvc.c b/xlators/protocol/rpc/rpc-lib/src/rpcsvc.c index 10d74759c..1e0a05e45 100644 --- a/xlators/protocol/rpc/rpc-lib/src/rpcsvc.c +++ b/xlators/protocol/rpc/rpc-lib/src/rpcsvc.c @@ -492,6 +492,7 @@ rpcsvc_conn_alloc (rpcsvc_t *svc, rpc_transport_t *trans) gf_log (GF_RPCSVC, GF_LOG_TRACE, "rx pool: %d", poolcount); conn->rxpool = mem_pool_new (rpcsvc_request_t, poolcount); + /* TODO: leak */ if (!conn->rxpool) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "mem pool allocation failed"); goto free_conn; |