diff --git a/include/maxscale/session.h b/include/maxscale/session.h index 77ab61b89..b2acc5797 100644 --- a/include/maxscale/session.h +++ b/include/maxscale/session.h @@ -395,18 +395,11 @@ bool session_store_stmt(SESSION *session, GWBUF *buf, const struct server *serve * The value returned by this call must be freed by the caller with gwbuf_free(). * * @param session Session with a stored statement - * @return Stored statement or NULL if no statement was stored + * @param buffer Pointer where the buffer is stored + * @param target Pointer where target server is stored + * @return True if a statement was stored */ -GWBUF* session_fetch_stmt(SESSION *session); - -/** - * Fetch the stored target - * - * @param session Session whose target is fetched - * @return The server where the statement is executed or NULL if no statement is - * stored - */ -const struct server* session_fetch_stmt_target(const SESSION *session); +bool session_take_stmt(SESSION *session, GWBUF **buffer, const struct server **target); /** * Clear the stored statement diff --git a/server/core/session.c b/server/core/session.c index 15810733b..5d47889fd 100644 --- a/server/core/session.c +++ b/server/core/session.c @@ -964,16 +964,20 @@ bool session_store_stmt(SESSION *session, GWBUF *buf, const SERVER *server) return rval; } -GWBUF *session_fetch_stmt(SESSION *session) +bool session_take_stmt(SESSION *session, GWBUF **buffer, const SERVER **target) { - GWBUF *rval = session->stmt.buffer; - session->stmt.buffer = NULL; - return rval; -} + bool rval = false; -const SERVER* session_fetch_stmt_target(const SESSION *session) -{ - return session->stmt.target; + if (session->stmt.buffer && session->stmt.target) + { + *buffer = session->stmt.buffer; + *target = session->stmt.target; + session->stmt.buffer = NULL; + session->stmt.target = NULL; + rval = true; + } + + return rval; } void session_clear_stmt(SESSION *session)