diff options
Diffstat (limited to 'rpc/rpc-lib/src/rpc-clnt.h')
| -rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 111 |
1 files changed, 82 insertions, 29 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 2381aaa08..584963ad0 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -1,24 +1,15 @@ /* - Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ -#ifndef _RPC_CLNT_H -#define _RPC_CLNT_H +#ifndef __RPC_CLNT_H +#define __RPC_CLNT_H #include "stack.h" #include "rpc-transport.h" @@ -31,7 +22,10 @@ typedef enum { RPC_CLNT_MSG } rpc_clnt_event_t; -#define AUTH_GLUSTERFS 5 + +#define SFRAME_GET_PROGNUM(sframe) (sframe->rpcreq->prog->prognum) +#define SFRAME_GET_PROGVER(sframe) (sframe->rpcreq->prog->progver) +#define SFRAME_GET_PROCNUM(sframe) (sframe->rpcreq->procnum) struct xptr_clnt; struct rpc_req; @@ -65,6 +59,7 @@ struct saved_frame { struct saved_frames { int64_t count; struct saved_frame sf; + struct saved_frame lk_sf; }; @@ -83,11 +78,45 @@ typedef struct rpc_clnt_program { int numproc; } rpc_clnt_prog_t; -#define RPC_MAX_AUTH_BYTES 400 +typedef int (*rpcclnt_cb_fn) (struct rpc_clnt *rpc, void *mydata, void *data); + +/* The descriptor for each procedure/actor that runs + * over the RPC service. + */ +typedef struct rpcclnt_actor_desc { + char procname[32]; + int procnum; + rpcclnt_cb_fn actor; +} rpcclnt_cb_actor_t; + +/* Describes a program and its version along with the function pointers + * required to handle the procedures/actors of each program/version. + * Never changed ever by any thread so no need for a lock. + */ +typedef struct rpcclnt_cb_program { + char progname[32]; + int prognum; + int progver; + rpcclnt_cb_actor_t *actors; /* All procedure handlers */ + int numactors; /* Num actors in actor array */ + + /* Program specific state handed to actors */ + void *private; + + + /* list member to link to list of registered services with rpc_clnt */ + struct list_head program; + + /* Needed for passing back in cb_actor */ + void *mydata; +} rpcclnt_cb_program_t; + + + typedef struct rpc_auth_data { - int flavour; - int datalen; - char authdata[RPC_MAX_AUTH_BYTES]; + int flavour; + int datalen; + char authdata[GF_MAX_AUTH_BYTES]; } rpc_auth_data_t; @@ -134,25 +163,32 @@ struct rpc_req { void *conn_private; }; -struct rpc_clnt { +typedef struct rpc_clnt { pthread_mutex_t lock; rpc_clnt_notify_t notifyfn; rpc_clnt_connection_t conn; void *mydata; uint64_t xid; + /* list of cb programs registered with rpc-clnt */ + struct list_head programs; + /* Memory pool for rpc_req_t */ struct mem_pool *reqpool; struct mem_pool *saved_frames_pool; glusterfs_ctx_t *ctx; -}; + int refcount; + int auth_null; + char disabled; +} rpc_clnt_t; -struct rpc_clnt * rpc_clnt_init (struct rpc_clnt_config *config, - dict_t *options, glusterfs_ctx_t *ctx, - char *name); +struct rpc_clnt *rpc_clnt_new (dict_t *options, glusterfs_ctx_t *ctx, + char *name, uint32_t reqpool_size); + +int rpc_clnt_start (struct rpc_clnt *rpc); int rpc_clnt_register_notify (struct rpc_clnt *rpc, rpc_clnt_notify_t fn, void *mydata); @@ -171,7 +207,7 @@ int rpc_clnt_register_notify (struct rpc_clnt *rpc, rpc_clnt_notify_t fn, * also be filled with pointer to buffer to hold header and length * of the header. */ - + int rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, struct iovec *proghdr, int proghdrcount, @@ -180,14 +216,31 @@ int rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int rsphdr_count, struct iovec *rsp_payload, int rsp_payload_count, struct iobref *rsp_iobref); -void rpc_clnt_destroy (struct rpc_clnt *rpc); +struct rpc_clnt * +rpc_clnt_ref (struct rpc_clnt *rpc); + +struct rpc_clnt * +rpc_clnt_unref (struct rpc_clnt *rpc); + +int rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn); void rpc_clnt_set_connected (rpc_clnt_connection_t *conn); void rpc_clnt_unset_connected (rpc_clnt_connection_t *conn); - void rpc_clnt_reconnect (void *trans_ptr); void rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config); +/* All users of RPC services should use this API to register their + * procedure handlers. + */ +int rpcclnt_cbk_program_register (struct rpc_clnt *svc, + rpcclnt_cb_program_t *program, void *mydata); + +void +rpc_clnt_disable (struct rpc_clnt *rpc); + +char +rpc_clnt_is_disabled (struct rpc_clnt *rpc); + #endif /* !_RPC_CLNT_H */ |
