summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-04-24 17:31:03 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-05-04 04:08:26 -0700
commitdc0020c72d5c2d20328b89224b149ebb87002277 (patch)
tree2eea570ce0e71620710e6217081114a495eefcb3 /rpc
parent9e6b521cc98b3ba099c1713639be9180be5b031f (diff)
rpc: Maintain separate xlator pointer in 'rpcsvc_state'
The structure 'rpcsvc_state', which maintains rpc server state had no separate pointer to track the translator. It was using the mydata pointer itself. So callers were forced to send xlator pointer as mydata which is opaque (void pointer) by function prototype. 'rpcsvc_register_init' is setting svc->mydata with xlator pointer. 'rpcsvc_register_notify' is overwriting svc->mydata with mydata pointer. And rpc interprets svc->mydata as xlator pointer internally. If someone passes non xlator structure pointer to rpcsvc_register_notify as libgfchangelog currently does, it might corrupt mydata. So interpreting opaque mydata as xlator pointer is incorrect as it is caller's choice to send mydata as any type of data to 'rpcsvc_register_notify'. Maintaining two different pointers in 'rpcsvc_state' for xlator and mydata solves the issue. Change-Id: I7874933fefc68f3fe01d44f92016a8e4e9768378 BUG: 1215161 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/10366 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpcsvc-common.h4
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c8
2 files changed, 7 insertions, 5 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h
index 832645bd12a..dd958032336 100644
--- a/rpc/rpc-lib/src/rpcsvc-common.h
+++ b/rpc/rpc-lib/src/rpcsvc-common.h
@@ -16,6 +16,7 @@
#include "compat.h"
#include "glusterfs.h"
#include "dict.h"
+#include "xlator.h"
typedef enum {
RPCSVC_EVENT_ACCEPT,
@@ -69,7 +70,8 @@ typedef struct rpcsvc_state {
struct list_head notify;
int notify_count;
- void *mydata; /* This is xlator */
+ xlator_t *xl; /* xlator */
+ void *mydata;
rpcsvc_notify_t notifyfn;
struct mem_pool *rxpool;
rpcsvc_drc_globals_t *drc;
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index b395149e032..be95d25b1b1 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -677,7 +677,7 @@ rpcsvc_handle_rpc_call (rpcsvc_t *svc, rpc_transport_t *trans,
if (req->rpc_err == SUCCESS) {
/* Before going to xlator code, set the THIS properly */
- THIS = svc->mydata;
+ THIS = svc->xl;
actor_fn = actor->actor;
@@ -1802,7 +1802,7 @@ rpcsvc_register_notify (rpcsvc_t *svc, rpcsvc_notify_t notify, void *mydata)
if (!wrapper) {
goto out;
}
- svc->mydata = mydata; /* this_xlator */
+ svc->mydata = mydata;
wrapper->data = mydata;
wrapper->notify = notify;
@@ -2045,7 +2045,7 @@ rpcsvc_reconfigure_options (rpcsvc_t *svc, dict_t *options)
return (-1);
/* Fetch the xlator from svc */
- xlator = (xlator_t *) svc->mydata;
+ xlator = svc->xl;
if (!xlator)
return (-1);
@@ -2311,7 +2311,7 @@ rpcsvc_init (xlator_t *xl, glusterfs_ctx_t *ctx, dict_t *options,
ret = -1;
svc->options = options;
svc->ctx = ctx;
- svc->mydata = xl;
+ svc->xl = xl;
gf_log (GF_RPCSVC, GF_LOG_DEBUG, "RPC service inited.");
gluster_dump_prog.options = options;