本文整理汇总了C++中xdr_to_generic函数的典型用法代码示例。如果您正苦于以下问题:C++ xdr_to_generic函数的具体用法?C++ xdr_to_generic怎么用?C++ xdr_to_generic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xdr_to_generic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mgmt_pmap_signout_cbk
static int
mgmt_pmap_signout_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
pmap_signout_rsp rsp = {0,};
int ret = 0;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_signout_rsp);
if (ret < 0) {
gf_log (THIS->name, GF_LOG_ERROR, "XDR decoding failed");
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (-1 == rsp.op_ret) {
gf_log (THIS->name, GF_LOG_ERROR,
"failed to register the port with glusterd");
goto out;
}
out:
return 0;
}
示例2: client_cbk_cache_invalidation
int
client_cbk_cache_invalidation (struct rpc_clnt *rpc, void *mydata, void *data)
{
int ret = -1;
struct iovec *iov = NULL;
struct gf_upcall upcall_data = {0,};
uuid_t gfid;
struct gf_upcall_cache_invalidation ca_data = {0,};
gfs3_cbk_cache_invalidation_req ca_req = {0,};
gf_msg_trace (THIS->name, 0, "Upcall callback is called");
if (!rpc || !mydata || !data)
goto out;
iov = (struct iovec *)data;
ret = xdr_to_generic (*iov, &ca_req,
(xdrproc_t)xdr_gfs3_cbk_cache_invalidation_req);
if (ret < 0) {
gf_msg (THIS->name, GF_LOG_WARNING, -ret,
PC_MSG_CACHE_INVALIDATION_FAIL,
"XDR decode of cache_invalidation failed.");
goto out;
}
upcall_data.data = &ca_data;
gf_proto_cache_invalidation_to_upcall (&ca_req, &upcall_data);
gf_msg_trace (THIS->name, 0, "Upcall gfid = %s, ret = %d",
ca_req.gfid, ret);
default_notify (THIS, GF_EVENT_UPCALL, &upcall_data);
out:
if (ca_req.gfid)
free (ca_req.gfid);
if (ca_req.xdata.xdata_val)
free (ca_req.xdata.xdata_val);
return 0;
}
示例3: xdr_to_fsstat3args
ssize_t
xdr_to_fsstat3args (struct iovec inmsg, fsstat3args *fa)
{
return xdr_to_generic (inmsg, (void *)fa,
(xdrproc_t)xdr_fsstat3args);
}
示例4: xdr_to_readdirp3args
ssize_t
xdr_to_readdirp3args (struct iovec inmsg, readdirp3args *rp)
{
return xdr_to_generic (inmsg, (void *)rp,
(xdrproc_t)xdr_readdirp3args);
}
示例5: xdr_to_link3args
ssize_t
xdr_to_link3args (struct iovec inmsg, link3args *la)
{
return xdr_to_generic (inmsg, (void *)la, (xdrproc_t)xdr_link3args);
}
示例6: xdr_to_rename3args
ssize_t
xdr_to_rename3args (struct iovec inmsg, rename3args *ra)
{
return xdr_to_generic (inmsg, (void *)ra,
(xdrproc_t)xdr_rename3args);
}
示例7: glusterd_handle_post_validate_fn
static int
glusterd_handle_post_validate_fn (rpcsvc_request_t *req)
{
int32_t ret = -1;
gd1_mgmt_v3_post_val_req op_req = {{0},};
xlator_t *this = NULL;
char *op_errstr = NULL;
dict_t *dict = NULL;
dict_t *rsp_dict = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
ret = xdr_to_generic (req->msg[0], &op_req,
(xdrproc_t)xdr_gd1_mgmt_v3_post_val_req);
if (ret < 0) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_REQ_DECODE_FAIL,
"Failed to decode post validation "
"request received from peer");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
if (glusterd_peerinfo_find_by_uuid (op_req.uuid) == NULL) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_PEER_NOT_FOUND, "%s doesn't "
"belong to the cluster. Ignoring request.",
uuid_utoa (op_req.uuid));
ret = -1;
goto out;
}
dict = dict_new ();
if (!dict)
goto out;
ret = dict_unserialize (op_req.dict.dict_val,
op_req.dict.dict_len, &dict);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_DICT_UNSERIALIZE_FAIL,
"failed to unserialize the dictionary");
goto out;
}
rsp_dict = dict_new ();
if (!rsp_dict) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_DICT_CREATE_FAIL,
"Failed to get new dictionary");
return -1;
}
ret = gd_mgmt_v3_post_validate_fn (op_req.op, op_req.op_ret, dict,
&op_errstr, rsp_dict);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_POST_VALIDATION_FAIL,
"Post Validation failed on operation %s",
gd_op_list[op_req.op]);
}
ret = glusterd_mgmt_v3_post_validate_send_resp (req, op_req.op,
ret, op_errstr,
rsp_dict);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_MGMTV3_OP_RESP_FAIL,
"Failed to send Post Validation "
"response for operation %s",
gd_op_list[op_req.op]);
goto out;
}
out:
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
free (op_req.dict.dict_val);
if (dict)
dict_unref (dict);
if (rsp_dict)
dict_unref (rsp_dict);
/* Return 0 from handler to avoid double deletion of req obj */
return 0;
}
示例8: xdr_to_setaclargs
ssize_t
xdr_to_setaclargs (struct iovec inmsg, setaclargs *args)
{
return xdr_to_generic (inmsg, (void *) args,
(xdrproc_t)xdr_setaclargs);
}
示例9: xdr_to_commit3args
ssize_t
xdr_to_commit3args (struct iovec inmsg, commit3args *ca)
{
return xdr_to_generic (inmsg, (void *)ca,
(xdrproc_t)xdr_commit3args);
}
示例10: xdr_to_access3args
ssize_t
xdr_to_access3args (struct iovec inmsg, access3args *ac)
{
return xdr_to_generic (inmsg,(void *)ac,
(xdrproc_t)xdr_access3args);
}
示例11: glusterd_handle_mgmt_v3_unlock_fn
static int
glusterd_handle_mgmt_v3_unlock_fn (rpcsvc_request_t *req)
{
gd1_mgmt_v3_unlock_req lock_req = {{0},};
int32_t ret = -1;
glusterd_op_lock_ctx_t *ctx = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
xlator_t *this = NULL;
gf_boolean_t is_synctasked = _gf_false;
gf_boolean_t free_ctx = _gf_false;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
ret = xdr_to_generic (req->msg[0], &lock_req,
(xdrproc_t)xdr_gd1_mgmt_v3_unlock_req);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "Failed to decode unlock "
"request received from peer");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
gf_log (this->name, GF_LOG_DEBUG, "Received volume unlock req "
"from uuid: %s", uuid_utoa (lock_req.uuid));
if (glusterd_friend_find_by_uuid (lock_req.uuid, &peerinfo)) {
gf_log (this->name, GF_LOG_WARNING, "%s doesn't "
"belong to the cluster. Ignoring request.",
uuid_utoa (lock_req.uuid));
ret = -1;
goto out;
}
ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t);
if (!ctx) {
ret = -1;
goto out;
}
uuid_copy (ctx->uuid, lock_req.uuid);
ctx->req = req;
ctx->dict = dict_new ();
if (!ctx->dict) {
ret = -1;
goto out;
}
ret = dict_unserialize (lock_req.dict.dict_val,
lock_req.dict.dict_len, &ctx->dict);
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"failed to unserialize the dictionary");
goto out;
}
is_synctasked = dict_get_str_boolean (ctx->dict,
"is_synctasked", _gf_false);
if (is_synctasked) {
ret = glusterd_syctasked_mgmt_v3_unlock (req, &lock_req, ctx);
/* The above function does not take ownership of ctx.
* Therefore we need to free the ctx explicitly. */
free_ctx = _gf_true;
}
else {
ret = glusterd_op_state_machine_mgmt_v3_unlock (req, &lock_req,
ctx);
}
out:
if (ret || free_ctx) {
if (ctx->dict)
dict_unref (ctx->dict);
if (ctx)
GF_FREE (ctx);
}
free (lock_req.dict.dict_val);
gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
示例12: glusterd_handle_post_validate_fn
static int
glusterd_handle_post_validate_fn (rpcsvc_request_t *req)
{
int32_t ret = -1;
gd1_mgmt_v3_post_val_req op_req = {{0},};
glusterd_peerinfo_t *peerinfo = NULL;
xlator_t *this = NULL;
char *op_errstr = NULL;
dict_t *dict = NULL;
dict_t *rsp_dict = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
ret = xdr_to_generic (req->msg[0], &op_req,
(xdrproc_t)xdr_gd1_mgmt_v3_post_val_req);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to decode post validation "
"request received from peer");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) {
gf_log (this->name, GF_LOG_WARNING, "%s doesn't "
"belong to the cluster. Ignoring request.",
uuid_utoa (op_req.uuid));
ret = -1;
goto out;
}
dict = dict_new ();
if (!dict)
goto out;
ret = dict_unserialize (op_req.dict.dict_val,
op_req.dict.dict_len, &dict);
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"failed to unserialize the dictionary");
goto out;
}
rsp_dict = dict_new ();
if (!rsp_dict) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to get new dictionary");
return -1;
}
ret = gd_mgmt_v3_post_validate_fn (op_req.op, op_req.op_ret, dict,
&op_errstr, rsp_dict);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Post Validation failed on operation %s",
gd_op_list[op_req.op]);
}
ret = glusterd_mgmt_v3_post_validate_send_resp (req, op_req.op,
ret, op_errstr,
rsp_dict);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to send Post Validation "
"response for operation %s",
gd_op_list[op_req.op]);
goto out;
}
out:
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
free (op_req.dict.dict_val);
if (dict)
dict_unref (dict);
if (rsp_dict)
dict_unref (rsp_dict);
gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
示例13: xdr_to_dump_rsp
ssize_t
xdr_to_dump_rsp (struct iovec inmsg, void *args)
{
return xdr_to_generic (inmsg, (void *)args,
(xdrproc_t)xdr_gf_dump_rsp);
}
示例14: quotad_aggregator_getlimit
int
quotad_aggregator_getlimit (rpcsvc_request_t *req)
{
call_frame_t *frame = NULL;
gf_cli_req cli_req = {{0}, };
gf_cli_rsp cli_rsp = {0};
gfs3_lookup_req args = {{0,},};
gfs3_lookup_rsp rsp = {0,};
quotad_aggregator_state_t *state = NULL;
xlator_t *this = NULL;
dict_t *dict = NULL;
int ret = -1, op_errno = 0;
char *gfid_str = NULL;
uuid_t gfid = {0};
GF_VALIDATE_OR_GOTO ("quotad-aggregator", req, err);
this = THIS;
ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req);
if (ret < 0) {
//failed to decode msg;
gf_log ("", GF_LOG_ERROR, "xdr decoding error");
req->rpc_err = GARBAGE_ARGS;
goto err;
}
if (cli_req.dict.dict_len) {
dict = dict_new ();
ret = dict_unserialize (cli_req.dict.dict_val,
cli_req.dict.dict_len, &dict);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "Failed to "
"unserialize req-buffer to dictionary");
goto err;
}
}
ret = dict_get_str (dict, "gfid", &gfid_str);
if (ret) {
goto err;
}
uuid_parse ((const char*)gfid_str, gfid);
frame = quotad_aggregator_get_frame_from_req (req);
if (frame == NULL) {
rsp.op_errno = ENOMEM;
goto err;
}
state = frame->root->state;
state->xdata = dict;
ret = dict_set_int32 (state->xdata, QUOTA_LIMIT_KEY, 42);
if (ret)
goto err;
ret = dict_set_int32 (state->xdata, QUOTA_SIZE_KEY, 42);
if (ret)
goto err;
ret = dict_set_int32 (state->xdata, GET_ANCESTRY_PATH_KEY,42);
if (ret)
goto err;
memcpy (&args.gfid, &gfid, 16);
args.bname = alloca (req->msg[0].iov_len);
args.xdata.xdata_val = alloca (req->msg[0].iov_len);
ret = qd_nameless_lookup (this, frame, &args, state->xdata,
quotad_aggregator_getlimit_cbk);
if (ret) {
rsp.op_errno = ret;
goto err;
}
return ret;
err:
cli_rsp.op_ret = -1;
cli_rsp.op_errno = op_errno;
cli_rsp.op_errstr = "";
quotad_aggregator_getlimit_cbk (this, frame, &cli_rsp);
dict_unref (dict);
return ret;
}
示例15: glusterd_handle_mgmt_v3_unlock_fn
static int
glusterd_handle_mgmt_v3_unlock_fn (rpcsvc_request_t *req)
{
gd1_mgmt_v3_unlock_req lock_req = {{0},};
int32_t ret = -1;
glusterd_op_lock_ctx_t *ctx = NULL;
xlator_t *this = NULL;
gf_boolean_t is_synctasked = _gf_false;
gf_boolean_t free_ctx = _gf_false;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
ret = xdr_to_generic (req->msg[0], &lock_req,
(xdrproc_t)xdr_gd1_mgmt_v3_unlock_req);
if (ret < 0) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_REQ_DECODE_FAIL, "Failed to decode unlock "
"request received from peer");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
gf_msg_debug (this->name, 0, "Received volume unlock req "
"from uuid: %s", uuid_utoa (lock_req.uuid));
if (glusterd_peerinfo_find_by_uuid (lock_req.uuid) == NULL) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_PEER_NOT_FOUND, "%s doesn't "
"belong to the cluster. Ignoring request.",
uuid_utoa (lock_req.uuid));
ret = -1;
goto out;
}
ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t);
if (!ctx) {
ret = -1;
goto out;
}
gf_uuid_copy (ctx->uuid, lock_req.uuid);
ctx->req = req;
ctx->dict = dict_new ();
if (!ctx->dict) {
ret = -1;
goto out;
}
ret = dict_unserialize (lock_req.dict.dict_val,
lock_req.dict.dict_len, &ctx->dict);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_DICT_UNSERIALIZE_FAIL,
"failed to unserialize the dictionary");
goto out;
}
is_synctasked = dict_get_str_boolean (ctx->dict,
"is_synctasked", _gf_false);
if (is_synctasked) {
ret = glusterd_syctasked_mgmt_v3_unlock (req, &lock_req, ctx);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_MGMTV3_UNLOCK_FAIL,
"Failed to release mgmt_v3_locks");
/* Ignore the return code, as it shouldn't be propagated
* from the handler function so as to avoid double
* deletion of the req
*/
ret = 0;
}
/* The above function does not take ownership of ctx.
* Therefore we need to free the ctx explicitly. */
free_ctx = _gf_true;
}
else {
/* Shouldn't ignore the return code here, and it should
* be propagated from the handler function as in failure
* case it doesn't delete the req object
*/
ret = glusterd_op_state_machine_mgmt_v3_unlock (req, &lock_req,
ctx);
if (ret)
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_MGMTV3_UNLOCK_FAIL,
"Failed to release mgmt_v3_locks");
}
out:
if (ctx && (ret || free_ctx)) {
if (ctx->dict)
dict_unref (ctx->dict);
GF_FREE (ctx);
}
//.........这里部分代码省略.........