MXS-1725 Replace macros with function
The macros MXS_SESSION_ROUTE_QUERY and MXS_SESSION_ROUTE_REPLY are now defined in terms of functions that do the actual stuff. Incidentally, the function session_route_reply() existed already but was not used. Now slightly rewritten so that it does not simply ignore misuse.
This commit is contained in:
@ -198,22 +198,42 @@ typedef struct session
|
||||
skygw_chk_t ses_chk_tail;
|
||||
} MXS_SESSION;
|
||||
|
||||
|
||||
/**
|
||||
* Function to be used by protocol module for routing incoming data
|
||||
* to the first component in the pipeline of filters and a router.
|
||||
*
|
||||
* @param session The session.
|
||||
* @param buffer A buffer.
|
||||
*
|
||||
* @return True, if the routing should continue, false otherwise.
|
||||
*/
|
||||
bool session_route_query(MXS_SESSION *session, GWBUF *buffer);
|
||||
|
||||
/**
|
||||
* Function to be used by the router module to route the replies to
|
||||
* the first element in the pipeline of filters and a protocol.
|
||||
*
|
||||
* @param session The session.
|
||||
* @param buffer A buffer.
|
||||
*
|
||||
* @return True, if the routing should continue, false otherwise.
|
||||
*/
|
||||
bool session_route_reply(MXS_SESSION *session, GWBUF *buffer);
|
||||
|
||||
/**
|
||||
* A convenience macro that can be used by the protocol modules to route
|
||||
* the incoming data to the first element in the pipeline of filters and
|
||||
* routers.
|
||||
*/
|
||||
#define MXS_SESSION_ROUTE_QUERY(sess, buf) \
|
||||
((sess)->head.routeQuery)((sess)->head.instance, \
|
||||
(sess)->head.session, (buf))
|
||||
#define MXS_SESSION_ROUTE_QUERY(sess, buf) session_route_query(sess, buf)
|
||||
|
||||
/**
|
||||
* A convenience macro that can be used by the router modules to route
|
||||
* the replies to the first element in the pipeline of filters and
|
||||
* the protocol.
|
||||
*/
|
||||
#define MXS_SESSION_ROUTE_REPLY(sess, buf) \
|
||||
((sess)->tail.clientReply)((sess)->tail.instance, \
|
||||
(sess)->tail.session, (buf))
|
||||
#define MXS_SESSION_ROUTE_REPLY(sess, buf) session_route_reply(sess, buf)
|
||||
|
||||
/**
|
||||
* Allocate a new session for a new client of the specified service.
|
||||
|
||||
@ -702,30 +702,47 @@ session_get_remote(const MXS_SESSION *session)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool session_route_query(MXS_SESSION* ses, GWBUF* buf)
|
||||
bool session_route_query(MXS_SESSION* session, GWBUF* buffer)
|
||||
{
|
||||
bool succp;
|
||||
ss_dassert(session);
|
||||
ss_dassert(session->head.routeQuery);
|
||||
ss_dassert(session->head.instance);
|
||||
ss_dassert(session->head.session);
|
||||
|
||||
if (ses->head.routeQuery == NULL ||
|
||||
ses->head.instance == NULL ||
|
||||
ses->head.session == NULL)
|
||||
{
|
||||
succp = false;
|
||||
goto return_succp;
|
||||
}
|
||||
bool rv;
|
||||
|
||||
if (ses->head.routeQuery(ses->head.instance, ses->head.session, buf) == 1)
|
||||
if (session->head.routeQuery(session->head.instance, session->head.session, buffer) == 1)
|
||||
{
|
||||
succp = true;
|
||||
rv = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
succp = false;
|
||||
rv = false;
|
||||
}
|
||||
return_succp:
|
||||
return succp;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool session_route_reply(MXS_SESSION *session, GWBUF *buffer)
|
||||
{
|
||||
ss_dassert(session);
|
||||
ss_dassert(session->tail.clientReply);
|
||||
ss_dassert(session->tail.instance);
|
||||
ss_dassert(session->tail.session);
|
||||
|
||||
bool rv;
|
||||
|
||||
if (session->tail.clientReply(session->tail.instance, session->tail.session, buffer) == 1)
|
||||
{
|
||||
rv = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = false;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the username of the user connected to the client side of the
|
||||
|
||||
Reference in New Issue
Block a user