Cache: Derived CacheFilterSession from maxscale::FilterSession
This commit is contained in:
8
server/modules/filter/cache/cachefilter.cc
vendored
8
server/modules/filter/cache/cachefilter.cc
vendored
@ -272,7 +272,9 @@ static void setDownstream(FILTER* pInstance, void* pSessionData, DOWNSTREAM* pDo
|
||||
{
|
||||
CacheFilterSession* pCacheFilterSession = static_cast<CacheFilterSession*>(pSessionData);
|
||||
|
||||
MXS_EXCEPTION_GUARD(pCacheFilterSession->setDownstream(pDownstream));
|
||||
CacheFilterSession::Downstream down(*pDownstream);
|
||||
|
||||
MXS_EXCEPTION_GUARD(pCacheFilterSession->setDownstream(down));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,7 +288,9 @@ static void setUpstream(FILTER* pInstance, void* pSessionData, UPSTREAM* pUpstre
|
||||
{
|
||||
CacheFilterSession* pCacheFilterSession = static_cast<CacheFilterSession*>(pSessionData);
|
||||
|
||||
MXS_EXCEPTION_GUARD(pCacheFilterSession->setUpstream(pUpstream));
|
||||
CacheFilterSession::Upstream up(*pUpstream);
|
||||
|
||||
MXS_EXCEPTION_GUARD(pCacheFilterSession->setUpstream(up));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,16 +19,14 @@
|
||||
#include <maxscale/mysql_utils.h>
|
||||
#include "storage.h"
|
||||
|
||||
CacheFilterSession::CacheFilterSession(Cache* pCache, SESSION* pSession, char* zDefaultDb)
|
||||
: m_state(CACHE_EXPECTING_NOTHING)
|
||||
CacheFilterSession::CacheFilterSession(SESSION* pSession, Cache* pCache, char* zDefaultDb)
|
||||
: maxscale::FilterSession(pSession)
|
||||
, m_state(CACHE_EXPECTING_NOTHING)
|
||||
, m_pCache(pCache)
|
||||
, m_pSession(pSession)
|
||||
, m_zDefaultDb(zDefaultDb)
|
||||
, m_zUseDb(NULL)
|
||||
, m_refreshing(false)
|
||||
{
|
||||
memset(&m_down, 0, sizeof(m_down));
|
||||
memset(&m_up, 0, sizeof(m_up));
|
||||
memset(m_key.data, 0, CACHE_KEY_MAXLEN);
|
||||
|
||||
reset_response_state();
|
||||
@ -58,7 +56,7 @@ CacheFilterSession* CacheFilterSession::Create(Cache* pCache, SESSION* pSession)
|
||||
|
||||
if ((pMysqlSession->db[0] == 0) || zDefaultDb)
|
||||
{
|
||||
pCacheFilterSession = new (std::nothrow) CacheFilterSession(pCache, pSession, zDefaultDb);
|
||||
pCacheFilterSession = new (std::nothrow) CacheFilterSession(pSession, pCache, zDefaultDb);
|
||||
|
||||
if (!pCacheFilterSession)
|
||||
{
|
||||
@ -73,16 +71,6 @@ void CacheFilterSession::close()
|
||||
{
|
||||
}
|
||||
|
||||
void CacheFilterSession::setDownstream(DOWNSTREAM* pDown)
|
||||
{
|
||||
m_down = *pDown;
|
||||
}
|
||||
|
||||
void CacheFilterSession::setUpstream(UPSTREAM* pUp)
|
||||
{
|
||||
m_up = *pUp;
|
||||
}
|
||||
|
||||
int CacheFilterSession::routeQuery(GWBUF* pPacket)
|
||||
{
|
||||
uint8_t* pData = static_cast<uint8_t*>(GWBUF_DATA(pPacket));
|
||||
@ -231,7 +219,7 @@ int CacheFilterSession::routeQuery(GWBUF* pPacket)
|
||||
|
||||
if (fetch_from_server)
|
||||
{
|
||||
rv = m_down.routeQuery(m_down.instance, m_down.session, pPacket);
|
||||
rv = m_down.routeQuery(pPacket);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -584,7 +572,7 @@ int CacheFilterSession::send_upstream()
|
||||
{
|
||||
ss_dassert(m_res.pData != NULL);
|
||||
|
||||
int rv = m_up.clientReply(m_up.instance, m_up.session, m_res.pData);
|
||||
int rv = m_up.clientReply(m_res.pData);
|
||||
m_res.pData = NULL;
|
||||
|
||||
return rv;
|
||||
|
@ -14,14 +14,12 @@
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <maxscale/buffer.h>
|
||||
#include <maxscale/filter.h>
|
||||
#include <maxscale/filter.hh>
|
||||
#include "cache.h"
|
||||
#include "cachefilter.h"
|
||||
#include "cache_storage_api.h"
|
||||
|
||||
class Cache;
|
||||
|
||||
class CacheFilterSession
|
||||
class CacheFilterSession : public maxscale::FilterSession
|
||||
{
|
||||
public:
|
||||
enum cache_session_state_t
|
||||
@ -67,20 +65,6 @@ public:
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Set the downstream component for this session.
|
||||
*
|
||||
* @param pDown The downstream filter or router
|
||||
*/
|
||||
void setDownstream(DOWNSTREAM* pDownstream);
|
||||
|
||||
/**
|
||||
* Set the upstream component for this session.
|
||||
*
|
||||
* @param pUp The upstream filter or router
|
||||
*/
|
||||
void setUpstream(UPSTREAM* pUpstream);
|
||||
|
||||
/**
|
||||
* A request on its way to a backend is delivered to this function.
|
||||
*
|
||||
@ -122,7 +106,7 @@ private:
|
||||
void store_result();
|
||||
|
||||
private:
|
||||
CacheFilterSession(Cache* pCache, SESSION* pSession, char* zDefaultDb);
|
||||
CacheFilterSession(SESSION* pSession, Cache* pCache, char* zDefaultDb);
|
||||
|
||||
CacheFilterSession(const CacheFilterSession&);
|
||||
CacheFilterSession& operator = (const CacheFilterSession&);
|
||||
@ -130,9 +114,6 @@ private:
|
||||
private:
|
||||
cache_session_state_t m_state; /**< What state is the session in, what data is expected. */
|
||||
Cache* m_pCache; /**< The cache instance the session is associated with. */
|
||||
SESSION* m_pSession; /**< The session this data is associated with. */
|
||||
DOWNSTREAM m_down; /**< The previous filter or equivalent. */
|
||||
UPSTREAM m_up; /**< The next filter or equivalent. */
|
||||
CACHE_RESPONSE_STATE m_res; /**< The response state. */
|
||||
CACHE_KEY m_key; /**< Key storage. */
|
||||
char* m_zDefaultDb; /**< The default database. */
|
||||
|
Reference in New Issue
Block a user