Commit c3c29e08 authored by Marco De Marco's avatar Marco De Marco
Browse files

Small fix and refactoring

parent f2af4c39
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -275,7 +275,8 @@ void Client::handleReadResponseBody(const boost::system::error_code& errorCode)
        {
            ResponseSP response_sp(new Response);

            response_sp->ParseFromArray(&m_readBuff[HEADER_SIZE], m_readBuff.size() - HEADER_SIZE);
            response_sp->ParseFromArray(&m_readBuff[HEADER_SIZE],
                m_readBuff.size() - HEADER_SIZE);

            m_protocolManager_sp->processResponse(response_sp);

@@ -284,7 +285,8 @@ void Client::handleReadResponseBody(const boost::system::error_code& errorCode)
                m_requestResponseTimer.expires_from_now(
                    boost::posix_time::seconds(m_configuration_sp->getRefreshTime()));

                m_requestResponseTimer.async_wait(boost::bind(&Client::startWriteRequest, this));
                m_requestResponseTimer.async_wait(
                    boost::bind(&Client::startWriteRequest, this));
            }
            else
            {
+5 −5
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ void DBManager::connect() throw(soci::soci_error)
{
    DEBUG_STREAM << "DBManager::connect()" << endl;

    boost::mutex::scoped_lock lock(m_connectionPoolMutex);
    boost::mutex::scoped_lock lock(m_connectionMutex);

    std::stringstream connection;
    connection << " host=" << m_configuration_sp->getDatabaseHost();
@@ -72,7 +72,7 @@ void DBManager::disconnect()
{
    DEBUG_STREAM << "DBManager::disconnect()" << endl;

    boost::mutex::scoped_lock lock(m_connectionPoolMutex);
    boost::mutex::scoped_lock lock(m_connectionMutex);

    m_session_sp->close();
}
@@ -85,7 +85,7 @@ DBManager::InformationList DBManager::retrieveInformation(std::string schema,
{
    DEBUG_STREAM << "DBManager::retrieveInformation()" << endl;

    boost::mutex::scoped_lock lock(m_connectionPoolMutex);
    boost::mutex::scoped_lock lock(m_connectionMutex);

    if(m_session_sp->get_backend() == NULL)
        m_session_sp->reconnect();
@@ -117,7 +117,7 @@ std::tm DBManager::retrieveLastTimestamp(std::string schema, std::string table)
{
    DEBUG_STREAM << "DBManager::retrieveLastTimestamp()" << endl;

    boost::mutex::scoped_lock lock(m_connectionPoolMutex);
    boost::mutex::scoped_lock lock(m_connectionMutex);

    if(m_session_sp->get_backend() == NULL)
        m_session_sp->reconnect();
@@ -138,7 +138,7 @@ void DBManager::persistMetadata(std::string schema, std::string table,
{
    DEBUG_STREAM << "DBManager::persistMetadata()" << endl;

    boost::mutex::scoped_lock lock(m_connectionPoolMutex);
    boost::mutex::scoped_lock lock(m_connectionMutex);

    if(m_session_sp->get_backend() == NULL)
        m_session_sp->reconnect();
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ protected:
    Configuration::SP m_configuration_sp;

    //Connection mutex
    boost::mutex m_connectionPoolMutex;
    boost::mutex m_connectionMutex;

    //Database connection scoped pointer
    boost::scoped_ptr<soci::session> m_session_sp;
+7 −1
Original line number Diff line number Diff line
@@ -39,19 +39,25 @@ public:

protected:
//------------------------------------------------------------------------------
//  [Protected] Utilities methods
//  [Protected] Connection initialization methods
//------------------------------------------------------------------------------
    virtual void startConnect(boost::asio::ip::tcp::resolver::iterator);

    virtual void handleConnect(const boost::system::error_code&,
        boost::asio::ip::tcp::resolver::iterator);

//------------------------------------------------------------------------------
//  [Protected] Request response methods
//------------------------------------------------------------------------------
    virtual void startWriteRequest();

    virtual void startReadResponseHeader();

    virtual void startReadResponseBody(boost::uint32_t);

//------------------------------------------------------------------------------
//  [Protected] Connection close method
//------------------------------------------------------------------------------
    virtual void closeConnection();

//------------------------------------------------------------------------------
+3 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ void ProtocolManager::processResponse(ResponseSP response_sp)
{
    DEBUG_STREAM << "ProtocolManager::processResponse()" << endl;

    if(!response_sp->IsInitialized())
        throw std::runtime_error("Not initialized response!");

    switch(response_sp->type())
    {
        case Response::AUTHORIZATION:
Loading