Addition of the service, server, serv_protocol and session structure needed to tie the elements together.
Improvements to the protocol module support Documentation improvements Addition of make install target
This commit is contained in:
@ -36,6 +36,7 @@ struct server;
|
||||
* 01/06/13 Mark Riddoch Initial implementation
|
||||
* 11/06/13 Mark Riddoch Updated GWPROTOCOL structure with new
|
||||
* entry points
|
||||
* 18/06/13 Mark Riddoch Addition of the listener entry point
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -56,7 +57,12 @@ struct dcb;
|
||||
* connect Create a connection to the specified server
|
||||
* for the session pased in
|
||||
* close Gateway close entry point for the socket
|
||||
* listen Create a listener for the protocol
|
||||
* @endverbatim
|
||||
*
|
||||
* This forms the "module object" for protocol modules within the gateway.
|
||||
*
|
||||
* @see load_module
|
||||
*/
|
||||
typedef struct gw_protocol {
|
||||
int (*read)(struct dcb *, int);
|
||||
@ -67,16 +73,29 @@ typedef struct gw_protocol {
|
||||
int (*accept)(struct dcb *, int);
|
||||
int (*connect)(struct server *, struct session *, int);
|
||||
int (*close)(struct dcb *, int);
|
||||
int (*listen)(int, char *);
|
||||
} GWPROTOCOL;
|
||||
|
||||
/**
|
||||
* The statitics gathered on a descriptor control block
|
||||
*/
|
||||
typedef struct dcbstats {
|
||||
int n_reads; /**< Number of reads on this descriptor */
|
||||
int n_writes; /**< Number of writes on this descriptor */
|
||||
int n_accepts; /**< Number of accepts on this descriptor */
|
||||
int n_buffered; /**< Number of buffered writes */
|
||||
} DCBSTATS;
|
||||
/*
|
||||
|
||||
/**
|
||||
* Descriptor Control Block
|
||||
*
|
||||
* A wrapper for a network descriptor within the gateway, it contains all the
|
||||
* state information necessary to allow for the implementation of the asynchronous
|
||||
* operation of the potocol and gateway functions. It also provides links to the service
|
||||
* and session data that is required to route the information within the gateway.
|
||||
*
|
||||
* It is important to hold the state information here such that any thread within the
|
||||
* gateway may be selected to execute the required actions when a network event occurs.
|
||||
*/
|
||||
typedef struct dcb {
|
||||
int fd; /**< The descriptor */
|
||||
@ -94,13 +113,13 @@ typedef struct dcb {
|
||||
} DCB;
|
||||
|
||||
/* DCB states */
|
||||
#define DCB_STATE_ALLOC 0 /* Memory allocated but not populated */
|
||||
#define DCB_STATE_IDLE 1 /* Not yet in the poll mask */
|
||||
#define DCB_STATE_POLLING 2 /* Waiting in the poll loop */
|
||||
#define DCB_STATE_PROCESSING 4 /* Processing an event */
|
||||
#define DCB_STATE_LISTENING 5 /* The DCB is for a listening socket */
|
||||
#define DCB_STATE_DISCONNECTED 6 /* The socket is now closed */
|
||||
#define DCB_STATE_FREED 7 /* Memory freed */
|
||||
#define DCB_STATE_ALLOC 0 /**< Memory allocated but not populated */
|
||||
#define DCB_STATE_IDLE 1 /**< Not yet in the poll mask */
|
||||
#define DCB_STATE_POLLING 2 /**< Waiting in the poll loop */
|
||||
#define DCB_STATE_PROCESSING 4 /**< Processing an event */
|
||||
#define DCB_STATE_LISTENING 5 /**< The DCB is for a listening socket */
|
||||
#define DCB_STATE_DISCONNECTED 6 /**< The socket is now closed */
|
||||
#define DCB_STATE_FREED 7 /**< Memory freed */
|
||||
|
||||
/* A few useful macros */
|
||||
#define DCB_SESSION(x) (x)->session
|
||||
@ -109,6 +128,9 @@ typedef struct dcb {
|
||||
extern DCB *alloc_dcb(); /* Allocate a DCB */
|
||||
extern void free_dcb(DCB *); /* Free a DCB */
|
||||
extern DCB *connect_dcb(struct server *, struct session *, const char *);
|
||||
extern int dcb_read(DCB *, GWBUF **); /* Generic read routine */
|
||||
extern int dcb_write(DCB *, GWBUF *); /* Generic write routine */
|
||||
extern int dcb_drain_writeq(DCB *); /* Generic write routine */
|
||||
extern void printAllDCBs(); /* Debug to print all DCB in the system */
|
||||
extern void printDCB(DCB *); /* Debug print routine */
|
||||
extern const char *gw_dcb_state2string(int); /* DCB state to string */
|
||||
|
||||
Reference in New Issue
Block a user