summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-08-31 10:02:54 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-08-31 11:13:20 -0700
commite7cbae70c89c8813918d9deb3895cb6886cdaeeb (patch)
tree750a14a54b4a4558f39c7102908f72e79647a5fd /rpc
parent0b6e1ca3694201814fa4e32d81fa281290fd8ad9 (diff)
rpc-transport/socket: use xdr_sizeof instead of sizeof when trying to read vectored request/reply
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Vijay Bellur <vijay@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 'rpc')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 26b56fad577..f7d4d8e40d0 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -37,10 +37,12 @@
/* ugly #includes below */
#include "protocol-common.h"
#include "glusterfs3-xdr.h"
+#include "glusterfs3.h"
#include <fcntl.h>
#include <errno.h>
#include <netinet/tcp.h>
+#include <rpc/xdr.h>
#define GF_LOG_ERRNO(errno) ((errno == ENOTCONN) ? GF_LOG_DEBUG : GF_LOG_ERROR)
#define SA(ptr) ((struct sockaddr *)ptr)
@@ -737,6 +739,7 @@ __socket_read_vectored_request (rpc_transport_t *this)
struct iobuf *iobuf = NULL;
uint32_t remaining_size = 0;
uint32_t gluster_write_proc_len = 0;
+ gfs3_write_req write_req = {0, };
if (!this || !this->private)
goto out;
@@ -773,7 +776,15 @@ __socket_read_vectored_request (rpc_transport_t *this)
* here
*/
/* also read proc-header */
- gluster_write_proc_len = sizeof (gfs3_write_req);
+ gluster_write_proc_len = xdr_sizeof ((xdrproc_t) xdr_gfs3_write_req,
+ &write_req);
+
+ if (gluster_write_proc_len == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "xdr_sizeof on gfs3_write_req failed");
+ ret = -1;
+ goto out;
+ }
verflen = ntoh32 (*((uint32_t *)addr))
+ gluster_write_proc_len;
@@ -939,6 +950,7 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
int ret = 0;
struct iobuf *iobuf = NULL;
uint32_t gluster_read_rsp_hdr_len = 0;
+ gfs3_read_rsp read_rsp = {0, };
if (!this || !this->private)
goto out;
@@ -948,8 +960,15 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
switch (priv->incoming.frag.call_body.reply.accepted_success_state) {
case SP_STATE_ACCEPTED_SUCCESS_REPLY_INIT:
- gluster_read_rsp_hdr_len = sizeof (gfs3_read_rsp);
+ gluster_read_rsp_hdr_len = xdr_sizeof ((xdrproc_t) xdr_gfs3_read_rsp,
+ &read_rsp);
+ if (gluster_read_rsp_hdr_len == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "xdr_sizeof on gfs3_read_rsp failed");
+ ret = -1;
+ goto out;
+ }
__socket_proto_init_pending (priv, gluster_read_rsp_hdr_len);
priv->incoming.frag.call_body.reply.accepted_success_state