Added new entry point in router: errorReply
The routine if called from backend will ido: 1 reply error messages to client closing or not the session 2 open a new backend connection An action flag is passed to the routine.
This commit is contained in:
@ -29,6 +29,7 @@
|
|||||||
* and the diagnostic entry point
|
* and the diagnostic entry point
|
||||||
* 15/07/2013 Massimiliano Pinto Added clientReply entry point
|
* 15/07/2013 Massimiliano Pinto Added clientReply entry point
|
||||||
* 16/07/2013 Massimiliano Pinto Added router commands values
|
* 16/07/2013 Massimiliano Pinto Added router commands values
|
||||||
|
* 22/10/2013 Massimiliano Pinto Added router errorReply entry point
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <service.h>
|
#include <service.h>
|
||||||
@ -57,6 +58,8 @@ typedef void *ROUTER;
|
|||||||
* diagnostics Called to force the router to print
|
* diagnostics Called to force the router to print
|
||||||
* diagnostic output
|
* diagnostic output
|
||||||
* clientReply Called to reply to client the data from one or all backends
|
* clientReply Called to reply to client the data from one or all backends
|
||||||
|
* errorReply Called to reply to client errors with optional closeSession or
|
||||||
|
* make a request for a new backend connection
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*
|
*
|
||||||
@ -70,6 +73,7 @@ typedef struct router_object {
|
|||||||
int (*routeQuery)(ROUTER *instance, void *router_session, GWBUF *queue);
|
int (*routeQuery)(ROUTER *instance, void *router_session, GWBUF *queue);
|
||||||
void (*diagnostics)(ROUTER *instance, DCB *dcb);
|
void (*diagnostics)(ROUTER *instance, DCB *dcb);
|
||||||
void (*clientReply)(ROUTER* instance, void* router_session, GWBUF* queue, DCB *backend_dcb);
|
void (*clientReply)(ROUTER* instance, void* router_session, GWBUF* queue, DCB *backend_dcb);
|
||||||
|
void (*errorReply)(ROUTER* instance, void* router_session, char* message, DCB *backend_dcb, int action);
|
||||||
} ROUTER_OBJECT;
|
} ROUTER_OBJECT;
|
||||||
|
|
||||||
/* Router commands */
|
/* Router commands */
|
||||||
|
|||||||
@ -61,6 +61,7 @@ static ROUTER_OBJECT MyObject = {
|
|||||||
freeSession,
|
freeSession,
|
||||||
execute,
|
execute,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,8 @@
|
|||||||
* 31/07/2013 Massimiliano Pinto Added a check for candidate server, if NULL return
|
* 31/07/2013 Massimiliano Pinto Added a check for candidate server, if NULL return
|
||||||
* 12/08/2013 Mark Riddoch Log unsupported router options
|
* 12/08/2013 Mark Riddoch Log unsupported router options
|
||||||
* 04/09/2013 Massimiliano Pinto Added client NULL check in clientReply
|
* 04/09/2013 Massimiliano Pinto Added client NULL check in clientReply
|
||||||
|
* 22/10/2013 Massimiliano Pinto errorReply called from backend, for client error replyi
|
||||||
|
* or take different actions such as open a new backend connection
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -96,6 +98,12 @@ static void clientReply(
|
|||||||
void *router_session,
|
void *router_session,
|
||||||
GWBUF *queue,
|
GWBUF *queue,
|
||||||
DCB *backend_dcb);
|
DCB *backend_dcb);
|
||||||
|
static void errorReply(
|
||||||
|
ROUTER *instance,
|
||||||
|
void *router_session,
|
||||||
|
char *message,
|
||||||
|
DCB *backend_dcb,
|
||||||
|
int action);
|
||||||
|
|
||||||
/** The module object definition */
|
/** The module object definition */
|
||||||
static ROUTER_OBJECT MyObject = {
|
static ROUTER_OBJECT MyObject = {
|
||||||
@ -105,7 +113,8 @@ static ROUTER_OBJECT MyObject = {
|
|||||||
freeSession,
|
freeSession,
|
||||||
routeQuery,
|
routeQuery,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
clientReply
|
clientReply,
|
||||||
|
errorReply
|
||||||
};
|
};
|
||||||
|
|
||||||
static SPINLOCK instlock;
|
static SPINLOCK instlock;
|
||||||
@ -584,3 +593,31 @@ clientReply(
|
|||||||
client->func.write(client, queue);
|
client->func.write(client, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error Reply routine
|
||||||
|
*
|
||||||
|
* The routine will reply to client errors and/or closing the session
|
||||||
|
* or try to open a new backend connection.
|
||||||
|
*
|
||||||
|
* @param instance The router instance
|
||||||
|
* @param router_session The router session
|
||||||
|
* @param message The error message to reply
|
||||||
|
* @param backend_dcb The backend DCB
|
||||||
|
* @param action The action: REPLY, REPLY_AND_CLOSE, NEW_CONNECTION
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
errorReply(
|
||||||
|
ROUTER *instance,
|
||||||
|
void *router_session,
|
||||||
|
char *message,
|
||||||
|
DCB *backend_dcb,
|
||||||
|
int action)
|
||||||
|
{
|
||||||
|
DCB *client = NULL;
|
||||||
|
ROUTER_OBJECT *router = NULL;
|
||||||
|
SESSION *session = backend_dcb->session;
|
||||||
|
client = backend_dcb->session->client;
|
||||||
|
|
||||||
|
ss_dassert(client != NULL);
|
||||||
|
}
|
||||||
|
|||||||
@ -77,7 +77,8 @@ static ROUTER_OBJECT MyObject = {
|
|||||||
freeSession,
|
freeSession,
|
||||||
routeQuery,
|
routeQuery,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
clientReply
|
clientReply,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static SPINLOCK instlock;
|
static SPINLOCK instlock;
|
||||||
|
|||||||
@ -35,6 +35,7 @@ static ROUTER_OBJECT MyObject = {
|
|||||||
freeSession,
|
freeSession,
|
||||||
routeQuery,
|
routeQuery,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user