From: SomeDude Date: Wed, 7 May 2008 05:52:00 +0000 (+0200) Subject: version 0.2.14 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=14fff12d9df0ee30e2df4bf9d22c2e83065816df;p=fms.git version 0.2.14 --- diff --git a/include/global.h b/include/global.h index b1b315b..7dcc373 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.13" +#define FMS_VERSION "0.2.14" // opens database and creates tables and initial inserts if necessary void SetupDB(); @@ -38,6 +38,6 @@ void SetupNetwork(); // cleanup network on Windows void ShutdownNetwork(); -extern bool wantshutdown; +extern volatile bool wantshutdown; #endif // _global_ diff --git a/include/http/ipagehandler.h b/include/http/ipagehandler.h index 6cd3052..66e15b8 100644 --- a/include/http/ipagehandler.h +++ b/include/http/ipagehandler.h @@ -30,6 +30,7 @@ protected: void HandleMultiPartData(const std::string &contenttypeheader, char *data, const long datalen, std::map &args); // converts from basename[#] query args into a vector where the vector pos is the index pos # void CreateArgArray(const std::map &vars, const std::string &basename, std::vector &args); + const std::string CreateTrueFalseDropDown(const std::string &name, const std::string &selected); // replaces html control characters with elements (i.e. < becomes <) const std::string SanitizeOutput(const std::string &input); diff --git a/include/http/pages/homepage.h b/include/http/pages/homepage.h index d8eaa0c..0205557 100644 --- a/include/http/pages/homepage.h +++ b/include/http/pages/homepage.h @@ -2,8 +2,9 @@ #define _homepage_ #include "../ipagehandler.h" +#include "../../idatabase.h" -class HomePage:public IPageHandler +class HomePage:public IPageHandler,public IDatabase { public: HomePage(const std::string &templatestr):IPageHandler(templatestr) {} diff --git a/include/http/pages/localidentitiespage.h b/include/http/pages/localidentitiespage.h index bc687e1..71e0caa 100644 --- a/include/http/pages/localidentitiespage.h +++ b/include/http/pages/localidentitiespage.h @@ -12,8 +12,6 @@ private: const bool WillHandleURI(const std::string &uri); const std::string GeneratePage(const std::string &method, const std::map &queryvars); - const std::string CreateTrueFalseDropDown(const std::string &name, const std::string &selected); - }; #endif // _localidentitiespage_ diff --git a/src/fmsservice.cpp b/src/fmsservice.cpp index e24a53f..03e2b8e 100644 --- a/src/fmsservice.cpp +++ b/src/fmsservice.cpp @@ -1,5 +1,6 @@ #include "../include/fmsservice.h" #include "../include/global.h" +#include "../include/logfile.h" #include @@ -22,6 +23,7 @@ void ControlHandler(DWORD request) case SERVICE_CONTROL_SHUTDOWN: ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ControlHandler service got shutdown request"); wantshutdown=true; break; @@ -170,11 +172,17 @@ void ServiceMain(int argc, char** argv) ServiceStatus.dwCurrentState = SERVICE_RUNNING; SetServiceStatus (hStatus, &ServiceStatus); + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ServiceMain starting service"); + MainFunction(); + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ServiceMain stopping service"); + ServiceStatus.dwCurrentState=SERVICE_STOPPED; SetServiceStatus(hStatus,&ServiceStatus); + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ServiceMain returning"); + return; } diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index 66635bb..9bb4da8 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -22,8 +22,8 @@ IntroductionPuzzleInserter::IntroductionPuzzleInserter(FCPv2 *fcp):IFCPConnected void IntroductionPuzzleInserter::CheckForNeededInsert() { - // select all local ids that aren't single use and that aren't currently inserting a puzzle - SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE SingleUse='false' AND InsertingPuzzle='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;"); + // select all local ids that aren't single use and that aren't currently inserting a puzzle and are publishing a trust list + SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PublishTrustList='true' AND SingleUse='false' AND InsertingPuzzle='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;"); while(!rs.AtEnd()) { diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index 1a24bd0..39ffb36 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -252,8 +252,8 @@ void IntroductionPuzzleRequester::PopulateIDList() now.SetToGMTime(); - // select identities that aren't single use and have been seen today ( order by trust DESC and limit to limitnum ) - st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); + // select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum ) + st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+now.Format("%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";"); st.Step(); m_ids.clear(); diff --git a/src/global.cpp b/src/global.cpp index 38d51bc..ec296c1 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -17,7 +17,7 @@ #include #endif -bool wantshutdown=false; +volatile bool wantshutdown=false; std::string CreateShortIdentityName(const std::string &name, const std::string &publickey) { @@ -39,11 +39,18 @@ void SetupDB() { DateTime date; + std::string tempval=""; SQLite3DB::DB *db=SQLite3DB::DB::Instance(); db->Open("fms.db3"); db->SetBusyTimeout(10000); // set timeout to 10 seconds - //db->Execute("VACUUM;"); // not needed every startup + + tempval=""; + Option::Instance()->Get("VacuumOnStartup",tempval); + if(tempval=="true") + { + db->Execute("VACUUM;"); + } db->Execute("CREATE TABLE IF NOT EXISTS tblDBVersion(\ Major INTEGER,\ @@ -864,6 +871,12 @@ void SetupDefaultOptions() st.Step(); st.Reset(); + st.Bind(0,"VacuumOnStartup"); + st.Bind(1,"false"); + st.Bind(2,"VACUUM the database every time FMS starts. This will defragment the free space in the database and create a smaller database file. Vacuuming the database can be CPU and disk intensive."); + st.Step(); + st.Reset(); + } void SetupLogFile() @@ -903,6 +916,9 @@ void SetupNetwork() void Shutdown() { + + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"FMS starting shutdown"); + ThreadController::Instance()->ShutdownThreads(); ShutdownNetwork(); diff --git a/src/http/ipagehandler.cpp b/src/http/ipagehandler.cpp index 8599c23..6edd8ac 100644 --- a/src/http/ipagehandler.cpp +++ b/src/http/ipagehandler.cpp @@ -33,6 +33,28 @@ void IPageHandler::CreateArgArray(const std::map &vars, } } +const std::string IPageHandler::CreateTrueFalseDropDown(const std::string &name, const std::string &selected) +{ + std::string rval=""; + + rval+=""; content+=""; content+=""; content+="

"; + return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); } diff --git a/src/http/pages/localidentitiespage.cpp b/src/http/pages/localidentitiespage.cpp index 8b26238..3fd3c48 100644 --- a/src/http/pages/localidentitiespage.cpp +++ b/src/http/pages/localidentitiespage.cpp @@ -7,28 +7,6 @@ #include #endif -const std::string LocalIdentitiesPage::CreateTrueFalseDropDown(const std::string &name, const std::string &selected) -{ - std::string rval=""; - - rval+=""+option+""; content+=""; - content+=""; + + if(value!="true" && value!="false") + { + content+=""; + } + else + { + content+=CreateTrueFalseDropDown("value["+countstr+"]",value); + } + content+=""+description+""; content+=""; st.Step(); diff --git a/src/localidentity.cpp b/src/localidentity.cpp index 35843a3..fc749b9 100644 --- a/src/localidentity.cpp +++ b/src/localidentity.cpp @@ -57,4 +57,4 @@ const bool LocalIdentity::Load(const std::string &name) { return false; } -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index 69edc54..c2c499f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -134,5 +134,7 @@ void MainFunction() PThread::Sleep(1000); }while(!wantshutdown); + LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"FMS wants to shutdown"); + Shutdown(); } diff --git a/src/message.cpp b/src/message.cpp index d7aaf3f..53d8b34 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -729,50 +729,56 @@ const bool Message::StartFreenetInsert() MessageXML xml; int localidentityid=-1; - xml.SetMessageID(m_messageuuid); - xml.SetSubject(m_subject); - xml.SetBody(m_body); - xml.SetReplyBoard(m_replyboardname); - xml.SetDate(m_datetime.Format("%Y-%m-%d")); - xml.SetTime(m_datetime.Format("%H:%M:%S")); - StripAdministrationBoards(); - for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++) - { - xml.AddBoard((*i)); - } - - for(std::map::iterator j=m_inreplyto.begin(); j!=m_inreplyto.end(); j++) - { - xml.AddInReplyTo((*j).first,(*j).second); - } - localidentityid=FindLocalIdentityID(m_fromname); - if(localidentityid==-1) + if(m_boards.size()>0) { - return false; - } - SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML) VALUES(?,?,?);"); - st.Bind(0,localidentityid); - st.Bind(1,m_messageuuid); - st.Bind(2,xml.GetXML()); - st.Step(); + xml.SetMessageID(m_messageuuid); + xml.SetSubject(m_subject); + xml.SetBody(m_body); + xml.SetReplyBoard(m_replyboardname); + xml.SetDate(m_datetime.Format("%Y-%m-%d")); + xml.SetTime(m_datetime.Format("%H:%M:%S")); + + for(std::vector::iterator i=m_boards.begin(); i!=m_boards.end(); i++) + { + xml.AddBoard((*i)); + } + + for(std::map::iterator j=m_inreplyto.begin(); j!=m_inreplyto.end(); j++) + { + xml.AddInReplyTo((*j).first,(*j).second); + } - // insert file attachments into database - st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); - for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) - { - st.Bind(0,m_messageuuid); - st.Bind(1,(*i).m_filename); - st.Bind(2,(long)(*i).m_data.size()); - st.Bind(3,(*i).m_mimetype); - st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); + localidentityid=FindLocalIdentityID(m_fromname); + if(localidentityid==-1) + { + return false; + } + + SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblMessageInserts(LocalIdentityID,MessageUUID,MessageXML) VALUES(?,?,?);"); + st.Bind(0,localidentityid); + st.Bind(1,m_messageuuid); + st.Bind(2,xml.GetXML()); st.Step(); - st.Reset(); - } - HandleChangeTrust(); + // insert file attachments into database + st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);"); + for(std::vector::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++) + { + st.Bind(0,m_messageuuid); + st.Bind(1,(*i).m_filename); + st.Bind(2,(long)(*i).m_data.size()); + st.Bind(3,(*i).m_mimetype); + st.Bind(4,&((*i).m_data[0]),(*i).m_data.size()); + st.Step(); + st.Reset(); + } + + HandleChangeTrust(); + + } return true;