summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src/rpc-clnt.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-02-14 15:05:19 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-20 00:46:27 -0800
commitc0b8e886cac4ef0f16d5f93adab02229bb1414cd (patch)
tree03f5bc6550d5f2501d5b968776f4bb0ee8025310 /rpc/rpc-lib/src/rpc-clnt.c
parent975933a25d14cbac861e809b40c6edd01acaa28d (diff)
iobuf: use 'iobuf_get2()' to get variable sized buffers
added 'TODO' in places where it is missing. Change-Id: Ia802c94e3bb76930f7c88c990f078525be5459f5 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 765264 Reviewed-on: http://review.gluster.com/388 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'rpc/rpc-lib/src/rpc-clnt.c')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 631d7fcf7..540c72c82 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -1117,7 +1117,7 @@ ret:
int
-rpc_clnt_fill_request (int prognum, int progver, int procnum, int payload,
+rpc_clnt_fill_request (int prognum, int progver, int procnum,
uint64_t xid, struct auth_glusterfs_parms_v2 *au,
struct rpc_msg *request, char *auth_data)
{
@@ -1197,7 +1197,7 @@ out:
struct iobuf *
rpc_clnt_record_build_record (struct rpc_clnt *clnt, int prognum, int progver,
- int procnum, size_t payload, uint64_t xid,
+ int procnum, size_t hdrsize, uint64_t xid,
struct auth_glusterfs_parms_v2 *au,
struct iovec *recbuf)
{
@@ -1207,16 +1207,19 @@ rpc_clnt_record_build_record (struct rpc_clnt *clnt, int prognum, int progver,
struct iovec recordhdr = {0, };
size_t pagesize = 0;
int ret = -1;
+ size_t xdr_size = 0;
char auth_data[GF_MAX_AUTH_BYTES] = {0, };
if ((!clnt) || (!recbuf) || (!au)) {
goto out;
}
+ xdr_size = xdr_sizeof ((xdrproc_t)xdr_callmsg, &request);
+
/* First, try to get a pointer into the buffer which the RPC
* layer can use.
*/
- request_iob = iobuf_get (clnt->ctx->iobuf_pool);
+ request_iob = iobuf_get2 (clnt->ctx->iobuf_pool, (xdr_size + hdrsize));
if (!request_iob) {
goto out;
}
@@ -1226,7 +1229,7 @@ rpc_clnt_record_build_record (struct rpc_clnt *clnt, int prognum, int progver,
record = iobuf_ptr (request_iob); /* Now we have it. */
/* Fill the rpc structure and XDR it into the buffer got above. */
- ret = rpc_clnt_fill_request (prognum, progver, procnum, payload, xid,
+ ret = rpc_clnt_fill_request (prognum, progver, procnum, xid,
au, &request, auth_data);
if (ret == -1) {
gf_log (clnt->conn.trans->name, GF_LOG_WARNING,
@@ -1235,7 +1238,7 @@ rpc_clnt_record_build_record (struct rpc_clnt *clnt, int prognum, int progver,
}
recordhdr = rpc_clnt_record_build_header (record, pagesize, &request,
- payload);
+ hdrsize);
if (!recordhdr.iov_base) {
gf_log (clnt->conn.trans->name, GF_LOG_ERROR,
@@ -1256,7 +1259,7 @@ out:
struct iobuf *
rpc_clnt_record (struct rpc_clnt *clnt, call_frame_t *call_frame,
- rpc_clnt_prog_t *prog,int procnum, size_t payload_len,
+ rpc_clnt_prog_t *prog, int procnum, size_t hdrlen,
struct iovec *rpchdr, uint64_t callid)
{
struct auth_glusterfs_parms_v2 au = {0, };
@@ -1292,12 +1295,9 @@ rpc_clnt_record (struct rpc_clnt *clnt, call_frame_t *call_frame,
", gid: %d, owner: %s", au.pid, au.uid, au.gid,
lkowner_utoa (&call_frame->root->lk_owner));
- /* Assuming the client program would like to speak to the same version of
- * program on server.
- */
request_iob = rpc_clnt_record_build_record (clnt, prog->prognum,
prog->progver,
- procnum, payload_len,
+ procnum, hdrlen,
callid, &au,
rpchdr);
if (!request_iob) {
@@ -1432,11 +1432,6 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
proglen += iov_length (proghdr, proghdrcount);
}
- if (progpayload) {
- proglen += iov_length (progpayload,
- progpayloadcount);
- }
-
request_iob = rpc_clnt_record (rpc, frame, prog,
procnum, proglen,
&rpchdr, callid);