Ejemplo n.º 1
0
int
rpc_clnt_ping (struct rpc_clnt *rpc)
{
        call_frame_t *frame = NULL;
        int32_t       ret   = -1;

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto fail;

        frame->local = rpc;

        ret = rpc_clnt_submit (rpc, &clnt_ping_prog,
                               GF_DUMP_PING, rpc_clnt_ping_cbk, NULL, 0,
                               NULL, 0, NULL, frame, NULL, 0, NULL, 0, NULL);
        if (ret) {
                gf_log (THIS->name, GF_LOG_ERROR,
                        "failed to start ping timer");
        }

        return ret;

fail:
        if (frame) {
                STACK_DESTROY (frame->root);
        }

        return ret;

}
Ejemplo n.º 2
0
int
rpc_clnt_ping (struct rpc_clnt *rpc)
{
        call_frame_t *frame = NULL;
        int32_t       ret   = -1;
        rpc_clnt_connection_t *conn = NULL;

        conn = &rpc->conn;
        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                return ret;

        frame->local = rpc;

        ret = rpc_clnt_submit (rpc, &clnt_ping_prog,
                               GF_DUMP_PING, rpc_clnt_ping_cbk, NULL, 0,
                               NULL, 0, NULL, frame, NULL, 0, NULL, 0, NULL);
        if (ret) {
                gf_log (THIS->name, GF_LOG_ERROR,
                        "failed to start ping timer");
        }
        else {
                /* ping successfully queued in list of saved frames
                 * for the connection*/
                pthread_mutex_lock (&conn->lock);
                conn->pingcnt++;
                pthread_mutex_unlock (&conn->lock);
        }

        return ret;

}
Ejemplo n.º 3
0
int
lic_submit_request(void *req, call_frame_t *frame, rpc_clnt_prog_t *prog,
		int procnum, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc)
{
        int                     ret         = -1;
        struct iovec            iov         = {0};
        struct iobuf            *iobuf      = NULL;
        ssize_t                 xdr_size    = 0;

        if (req) {
                xdr_size = xdr_sizeof(xdrproc, req);
                iobuf = iobuf_get2(THIS->ctx->iobuf_pool, xdr_size);
                if (!iobuf) {
                        goto out;
                };

                iov.iov_base = iobuf->ptr;
                iov.iov_len  = iobuf_size (iobuf);

                /* Create the xdr payload */
                ret = xdr_serialize_generic (iov, req, xdrproc);
                if (ret == -1)
                        goto out;

                iov.iov_len = ret;
        }

	lic_await_connected(60);

        /* Send the msg */
        ret = rpc_clnt_submit (g_rpc, prog, procnum, cbkfn,
                               &iov, 1,
                               NULL, 0, NULL, frame, NULL, 0, NULL, 0, NULL);
        ret = 0;

out:
        if (iobuf)
                iobuf_unref (iobuf);
        return ret;
}
Ejemplo n.º 4
0
int
rpc_clnt_mgmt_pmap_signout (glusterfs_ctx_t *ctx, char *brickname)
{
        int               ret = 0;
        pmap_signout_req  req = {0, };
        call_frame_t     *frame = NULL;
        cmd_args_t       *cmd_args = NULL;
        char              brick_name[PATH_MAX]  = {0,};
        struct iovec      iov = {0, };
        struct iobuf     *iobuf = NULL;
        struct iobref    *iobref = NULL;
        ssize_t           xdr_size = 0;

        frame = create_frame (THIS, ctx->pool);
        cmd_args = &ctx->cmd_args;

        if (!cmd_args->brick_port && (!cmd_args->brick_name || !brickname)) {
                gf_log ("fsd-mgmt", GF_LOG_DEBUG,
                        "portmapper signout arguments not given");
                goto out;
        }

        if (cmd_args->volfile_server_transport &&
            !strcmp(cmd_args->volfile_server_transport, "rdma")) {
                snprintf (brick_name, sizeof(brick_name), "%s.rdma",
                          cmd_args->brick_name);
                req.brick = brick_name;
        } else {
                if (brickname)
                        req.brick = brickname;
                else
                        req.brick = cmd_args->brick_name;
        }

        req.port  = cmd_args->brick_port;
        req.rdma_port = cmd_args->brick_port2;

        /* mgmt_submit_request is not available in libglusterfs.
         * Need to serialize and submit manually.
         */
        iobref = iobref_new ();
        if (!iobref) {
                goto out;
        }

        xdr_size = xdr_sizeof ((xdrproc_t)xdr_pmap_signout_req, &req);
        iobuf = iobuf_get2 (ctx->iobuf_pool, xdr_size);
        if (!iobuf) {
                goto out;
        };

        iobref_add (iobref, iobuf);

        iov.iov_base = iobuf->ptr;
        iov.iov_len  = iobuf_pagesize (iobuf);

        /* Create the xdr payload */
        ret = xdr_serialize_generic (iov, &req,
                                     (xdrproc_t)xdr_pmap_signout_req);
        if (ret == -1) {
                gf_log (THIS->name, GF_LOG_WARNING,
                        "failed to create XDR payload");
                goto out;
        }
        iov.iov_len = ret;

        ret = rpc_clnt_submit (ctx->mgmt, &clnt_pmap_signout_prog,
                               GF_PMAP_SIGNOUT, mgmt_pmap_signout_cbk,
                               &iov, 1,
                               NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL);
out:
        if (iobref)
                iobref_unref (iobref);

        if (iobuf)
                iobuf_unref (iobuf);
        return ret;
}