Loading src/blogi.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <signal.h> #include <string.h> #include <errno.h> #include <thread> #include <netplus/exception.h> Loading @@ -53,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pgsql.cpp" #include "sqlite.cpp" blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(serversocket){ PlgArgs = new PluginArgs; Loading Loading @@ -354,10 +356,8 @@ RETRY_REQUEST: }catch(libhttppp::HTTPException &e){ if(!PlgArgs->database->isConnected()){ PlgArgs->database->reset(); if(PlgArgs->database->isConnected()){ goto RETRY_REQUEST; } } throw e; } }catch(libhttppp::HTTPException &e){ Loading src/database.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -95,9 +95,6 @@ blogi::DBResult::DBResult(){ firstRow=nullptr; } blogi::DBResult::~DBResult(){ } blogi::DBResult2 blogi::DBResult::operator[](int value){ DBResult2 result(this,value); return result; Loading src/database.h +18 −4 Original line number Diff line number Diff line Loading @@ -59,7 +59,21 @@ namespace blogi { class DBResult { public: DBResult(); ~DBResult(); ~DBResult(){ clear(); } void clear(){ Data *curres=firstRow; while(curres){ Data *next=curres->nextData; curres->nextData=nullptr; delete curres; curres = next; } firstRow=nullptr; }; DBResult2 operator[](int value); Loading @@ -73,9 +87,6 @@ namespace blogi { nextData=nullptr; } virtual ~Data(){ } int row; int col; std::vector<char> Column; Loading @@ -94,6 +105,9 @@ namespace blogi { row=value; } ~DBResult2(){ } const char *operator[](int value2){ for(DBResult::Data *pos=result->firstRow; pos; pos=pos->nextData){ if( row==pos->row && pos->col==value2){ Loading src/database/pgsql.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <mutex> #include <httppp/exception.h> #include <libpq-fe.h> Loading @@ -32,6 +34,9 @@ #include "../database.h" namespace blogi { std::mutex g_lock_mutex; class Postgresql : public Database{ public: Postgresql(const char *constr) : Database (constr) { Loading Loading @@ -59,12 +64,9 @@ namespace blogi { throw exp; } if(res.firstRow){ delete res.firstRow; } res.clear(); res.firstRow=nullptr; DBResult::Data *lastdat; DBResult::Data *lastdat=nullptr; int rcount=PQntuples(pres); Loading Loading @@ -94,13 +96,15 @@ namespace blogi { } bool isConnected() override{ const std::lock_guard<std::mutex> lock(g_lock_mutex); if(PQstatus(_dbconn)==CONNECTION_OK) return true; return false; } void reset() override{ // PQresetStart(_dbconn); const std::lock_guard<std::mutex> lock(g_lock_mutex); PQreset(_dbconn); } private: Loading src/database/sqlite.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -65,11 +65,8 @@ namespace blogi { sqlite3_stmt *prep; int rcount = 0; if(res.firstRow){ delete res.firstRow; } res.clear(); res.firstRow=nullptr; DBResult::Data *lastdat; const char *cssql=ssql; Loading Loading
src/blogi.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <signal.h> #include <string.h> #include <errno.h> #include <thread> #include <netplus/exception.h> Loading @@ -53,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pgsql.cpp" #include "sqlite.cpp" blogi::Blogi::Blogi(Config *blgcfg,netplus::socket *serversocket) : HttpEvent(serversocket){ PlgArgs = new PluginArgs; Loading Loading @@ -354,10 +356,8 @@ RETRY_REQUEST: }catch(libhttppp::HTTPException &e){ if(!PlgArgs->database->isConnected()){ PlgArgs->database->reset(); if(PlgArgs->database->isConnected()){ goto RETRY_REQUEST; } } throw e; } }catch(libhttppp::HTTPException &e){ Loading
src/database.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -95,9 +95,6 @@ blogi::DBResult::DBResult(){ firstRow=nullptr; } blogi::DBResult::~DBResult(){ } blogi::DBResult2 blogi::DBResult::operator[](int value){ DBResult2 result(this,value); return result; Loading
src/database.h +18 −4 Original line number Diff line number Diff line Loading @@ -59,7 +59,21 @@ namespace blogi { class DBResult { public: DBResult(); ~DBResult(); ~DBResult(){ clear(); } void clear(){ Data *curres=firstRow; while(curres){ Data *next=curres->nextData; curres->nextData=nullptr; delete curres; curres = next; } firstRow=nullptr; }; DBResult2 operator[](int value); Loading @@ -73,9 +87,6 @@ namespace blogi { nextData=nullptr; } virtual ~Data(){ } int row; int col; std::vector<char> Column; Loading @@ -94,6 +105,9 @@ namespace blogi { row=value; } ~DBResult2(){ } const char *operator[](int value2){ for(DBResult::Data *pos=result->firstRow; pos; pos=pos->nextData){ if( row==pos->row && pos->col==value2){ Loading
src/database/pgsql.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <mutex> #include <httppp/exception.h> #include <libpq-fe.h> Loading @@ -32,6 +34,9 @@ #include "../database.h" namespace blogi { std::mutex g_lock_mutex; class Postgresql : public Database{ public: Postgresql(const char *constr) : Database (constr) { Loading Loading @@ -59,12 +64,9 @@ namespace blogi { throw exp; } if(res.firstRow){ delete res.firstRow; } res.clear(); res.firstRow=nullptr; DBResult::Data *lastdat; DBResult::Data *lastdat=nullptr; int rcount=PQntuples(pres); Loading Loading @@ -94,13 +96,15 @@ namespace blogi { } bool isConnected() override{ const std::lock_guard<std::mutex> lock(g_lock_mutex); if(PQstatus(_dbconn)==CONNECTION_OK) return true; return false; } void reset() override{ // PQresetStart(_dbconn); const std::lock_guard<std::mutex> lock(g_lock_mutex); PQreset(_dbconn); } private: Loading
src/database/sqlite.cpp +1 −4 Original line number Diff line number Diff line Loading @@ -65,11 +65,8 @@ namespace blogi { sqlite3_stmt *prep; int rcount = 0; if(res.firstRow){ delete res.firstRow; } res.clear(); res.firstRow=nullptr; DBResult::Data *lastdat; const char *cssql=ssql; Loading