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;
|
skygw_chk_t ses_chk_tail;
|
||||||
} MXS_SESSION;
|
} 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
|
* 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
|
* the incoming data to the first element in the pipeline of filters and
|
||||||
* routers.
|
* routers.
|
||||||
*/
|
*/
|
||||||
#define MXS_SESSION_ROUTE_QUERY(sess, buf) \
|
#define MXS_SESSION_ROUTE_QUERY(sess, buf) session_route_query(sess, buf)
|
||||||
((sess)->head.routeQuery)((sess)->head.instance, \
|
|
||||||
(sess)->head.session, (buf))
|
|
||||||
/**
|
/**
|
||||||
* A convenience macro that can be used by the router modules to route
|
* 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 replies to the first element in the pipeline of filters and
|
||||||
* the protocol.
|
* the protocol.
|
||||||
*/
|
*/
|
||||||
#define MXS_SESSION_ROUTE_REPLY(sess, buf) \
|
#define MXS_SESSION_ROUTE_REPLY(sess, buf) session_route_reply(sess, buf)
|
||||||
((sess)->tail.clientReply)((sess)->tail.instance, \
|
|
||||||
(sess)->tail.session, (buf))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new session for a new client of the specified service.
|
* 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;
|
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 ||
|
bool rv;
|
||||||
ses->head.instance == NULL ||
|
|
||||||
ses->head.session == NULL)
|
|
||||||
{
|
|
||||||
succp = false;
|
|
||||||
goto return_succp;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
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
|
* Return the username of the user connected to the client side of the
|
||||||
|
|||||||
Reference in New Issue
Block a user