version 0.3.19
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Mon, 1 Sep 2008 08:12:00 +0000 (10:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 1 Sep 2008 08:12:00 +0000 (10:12 +0200)
20 files changed:
include/dbsetup.h
include/freenet/freenetmasterthread.h
include/freenet/identityintroductionrequester.h
include/freenet/iindexrequester.h
include/freenet/introductionpuzzlerequester.h
include/freenet/messagerequester.h
include/global.h
include/option.h
src/dbsetup.cpp
src/fmsapp.cpp
src/freenet/boardlistrequester.cpp
src/freenet/freenetmasterthread.cpp
src/freenet/identityintroductionrequester.cpp
src/freenet/identityrequester.cpp
src/freenet/introductionpuzzlerequester.cpp
src/freenet/messagelistrequester.cpp
src/freenet/messagerequester.cpp
src/freenet/trustlistrequester.cpp
src/nntp/nntpconnection.cpp
src/option.cpp

index e3618d6..2738e5a 100644 (file)
@@ -3,5 +3,7 @@
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
+// verifies DB isn't corrupt\r
+const bool VerifyDB();\r
 \r
 #endif // _dbsetup_\r
index 6b2fc0b..76d6102 100644 (file)
@@ -33,7 +33,7 @@ private:
        void Shutdown();\r
 \r
        std::string m_fcphost;\r
-       long m_fcpport;\r
+       int m_fcpport;\r
        FCPv2 m_fcp;\r
        std::vector<IFreenetRegistrable *> m_registrables;\r
        std::vector<IPeriodicProcessor *> m_processors;\r
index 6b3c18a..f6dac85 100644 (file)
@@ -37,7 +37,7 @@ private:
        std::map<long,bool> m_ids;\r
        std::vector<std::string> m_requesting;\r
        std::string m_messagebase;\r
-       long m_maxrequests;\r
+       int m_maxrequests;\r
 \r
 };\r
 \r
index b74e69a..678e43e 100644 (file)
@@ -51,7 +51,7 @@ protected:
        std::vector<IDTYPE> m_requesting;               // list of ids we are currently requesting from\r
 \r
        // these MUST be populated by child class\r
-       long m_maxrequests;\r
+       int m_maxrequests;\r
        std::string m_fcpuniquename;\r
 \r
 };\r
index 8dcec3f..a345d3d 100644 (file)
@@ -35,7 +35,7 @@ private:
 \r
        Poco::DateTime m_tempdate;\r
        std::string m_messagebase;\r
-       long m_maxrequests;\r
+       int m_maxrequests;\r
        std::vector<long> m_requesting;         // list of ids we are currently requesting from\r
        std::map<long,bool> m_ids;                      // map of all ids we know and whether we have requested file from them yet\r
        \r
index 17b577f..d458ccb 100644 (file)
@@ -20,9 +20,9 @@ private:
        const bool SaveToBoard(const std::string &boardname);\r
        const std::string GetIdentityName(const long identityid);\r
 \r
-       long m_maxdaysbackward;\r
-       long m_maxpeermessages;\r
-       long m_maxboardspermessage;\r
+       int m_maxdaysbackward;\r
+       int m_maxpeermessages;\r
+       int m_maxboardspermessage;\r
        bool m_savemessagesfromnewboards;\r
        bool m_localtrustoverrides;\r
        \r
index f2a9e56..6dd1730 100644 (file)
@@ -7,10 +7,10 @@
 \r
 #define VERSION_MAJOR          "0"\r
 #define VERSION_MINOR          "3"\r
-#define VERSION_RELEASE                "18"\r
+#define VERSION_RELEASE                "19"\r
 #define FMS_VERSION                    VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
-#define FMS_FREESITE_USK       "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/78/"\r
-#define FMS_VERSION_EDITION    "19"\r
+#define FMS_FREESITE_USK       "USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/79/"\r
+#define FMS_VERSION_EDITION    "20"\r
 \r
 typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
 \r
index c01621d..9de5adf 100644 (file)
@@ -11,6 +11,7 @@ class Option:public Singleton<Option>
 {\r
 public:\r
        const bool Get(const std::string &option, std::string &value);\r
+       const bool GetInt(const std::string &option, int &value);\r
        template<class T>\r
        void Set(const std::string &option, const T &value);\r
 private:\r
index 2eb5403..2e0a460 100644 (file)
@@ -549,3 +549,27 @@ void SetupDB()
        db->Execute("ANALYZE;");\r
 \r
 }\r
+\r
+const bool VerifyDB()\r
+{\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       SQLite3DB::Statement st=db->Prepare("PRAGMA integrity_check;");\r
+       st.Step();\r
+       if(st.RowReturned())\r
+       {\r
+               std::string res="";\r
+               st.ResultText(0,res);\r
+               if(res=="ok")\r
+               {\r
+                       return true;\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
index 8a462e2..01fcf9a 100644 (file)
@@ -162,7 +162,12 @@ int FMSApp::main(const std::vector<std::string> &args)
        // so we need to set the working directory again\r
        int rval=chdir(m_workingdirectory.c_str());\r
 \r
-       if(m_displayhelp)\r
+       if(VerifyDB()==false)\r
+       {\r
+               std::cout << "The FMS database failed verification.  It is most likely corrupt!" << std::endl;\r
+               logger().fatal("The FMS database failed verification.  It is most likely corrupt!");\r
+       }\r
+       else if(m_displayhelp)\r
        {\r
        }\r
        else if(m_showoptions)\r
index a39d1a6..eb95e91 100644 (file)
@@ -197,8 +197,7 @@ void BoardListRequester::Initialize()
        m_fcpuniquename="BoardListRequester";\r
        m_maxrequests=0;\r
 \r
-       Option::Instance()->Get("MaxBoardListRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+       Option::Instance()->GetInt("MaxBoardListRequests",m_maxrequests);\r
        if(m_maxrequests<0)\r
        {\r
                m_maxrequests=0;\r
index b957c50..c23ee27 100644 (file)
 \r
 FreenetMasterThread::FreenetMasterThread()\r
 {\r
-       std::string fcpport;\r
 \r
        if(Option::Instance()->Get("FCPHost",m_fcphost)==false)\r
        {\r
                m_fcphost="localhost";\r
                Option::Instance()->Set("FCPHost",m_fcphost);\r
        }\r
-       if(Option::Instance()->Get("FCPPort",fcpport)==false)\r
+       if(Option::Instance()->GetInt("FCPPort",m_fcpport)==false)\r
        {\r
-               fcpport="9481";\r
-               Option::Instance()->Set("FCPPort",fcpport);\r
+               m_fcpport=9481;\r
+               Option::Instance()->Set("FCPPort",m_fcpport);\r
        }\r
-\r
-       // convert fcp port to long, and make sure it's within the valid port range\r
-       if(StringFunctions::Convert(fcpport,m_fcpport)==false)\r
+       else\r
        {\r
-               m_fcpport=9481;\r
-               Option::Instance()->Set("FCPPort","9481");\r
+               if(m_fcpport<1 || m_fcpport>65535)\r
+               {\r
+                       m_fcpport=9481;\r
+                       Option::Instance()->Set("FCPPort",m_fcpport);\r
+               }\r
        }\r
 \r
        m_receivednodehello=false;\r
index 6552770..843ed0a 100644 (file)
@@ -181,17 +181,16 @@ const bool IdentityIntroductionRequester::HandleMessage(FCPMessage &message)
 \r
 void IdentityIntroductionRequester::Initialize()\r
 {\r
-       std::string tempval="";\r
-       Option::Instance()->Get("MaxIdentityIntroductionRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+       m_maxrequests=0;\r
+       Option::Instance()->GetInt("MaxIdentityIntroductionRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
-               m_log->error("Option MaxIdentityIntroductionRequests is currently set at "+tempval+".  It must be 1 or greater.");\r
+               m_log->error("Option MaxIdentityIntroductionRequests is currently less than 1.  It must be 1 or greater.");\r
        }\r
        if(m_maxrequests>100)\r
        {\r
-               m_log->warning("Option MaxIdentityIntroductionRequests is currently set at "+tempval+".  This value might be incorrectly configured.");\r
+               m_log->warning("Option MaxIdentityIntroductionRequests is currently set at more than 100.  This value might be incorrectly configured.");\r
        }\r
        Option::Instance()->Get("MessageBase",m_messagebase);\r
        m_tempdate=Poco::Timestamp();\r
index 3375f1d..9e055e0 100644 (file)
@@ -166,18 +166,16 @@ const bool IdentityRequester::HandleGetFailed(FCPMessage &message)
 \r
 void IdentityRequester::Initialize()\r
 {\r
-       std::string tempval="";\r
        m_fcpuniquename="IdentityRequester";\r
-       Option::Instance()->Get("MaxIdentityRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+       Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
-               m_log->error("Option MaxIdentityRequests is currently set at "+tempval+".  It must be 1 or greater.");\r
+               m_log->error("Option MaxIdentityRequests is currently set at less than 1.  It must be 1 or greater.");\r
        }\r
        if(m_maxrequests>100)\r
        {\r
-               m_log->warning("Option MaxIdentityRequests is currently set at "+tempval+".  This value might be incorrectly configured.");\r
+               m_log->warning("Option MaxIdentityRequests is currently set at more than 100.  This value might be incorrectly configured.");\r
        }\r
 }\r
 \r
index 66669b3..dabe818 100644 (file)
@@ -234,17 +234,16 @@ const bool IntroductionPuzzleRequester::HandleMessage(FCPMessage &message)
 \r
 void IntroductionPuzzleRequester::Initialize()\r
 {\r
-       std::string tempval="";\r
-       Option::Instance()->Get("MaxIntroductionPuzzleRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+       m_maxrequests=0;\r
+       Option::Instance()->GetInt("MaxIntroductionPuzzleRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
-               m_log->error("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+".  It must be 1 or greater.");\r
+               m_log->error("Option MaxIntroductionPuzzleRequests is currently set at less than 1.  It must be 1 or greater.");\r
        }\r
        if(m_maxrequests>100)\r
        {\r
-               m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at "+tempval+".  This value might be incorrectly configured.");\r
+               m_log->warning("Option MaxIntroductionPuzzleRequests is currently set at more than 100.  This value might be incorrectly configured.");\r
        }\r
        Option::Instance()->Get("MessageBase",m_messagebase);\r
        m_tempdate=Poco::Timestamp();\r
index 24f70d1..1d42675 100644 (file)
@@ -303,9 +303,10 @@ const bool MessageListRequester::HandleGetFailed(FCPMessage &message)
 void MessageListRequester::Initialize()\r
 {\r
        m_fcpuniquename="MessageListRequester";\r
-       std::string tempval;\r
-       Option::Instance()->Get("MaxMessageListRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+       std::string tempval="";\r
+\r
+       m_maxrequests=0;\r
+       Option::Instance()->GetInt("MaxMessageListRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
index c641c95..4ea393a 100644 (file)
@@ -324,8 +324,9 @@ void MessageRequester::Initialize()
 {\r
        m_fcpuniquename="MessageRequester";\r
        std::string tempval;\r
-       Option::Instance()->Get("MaxMessageRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+\r
+       m_maxrequests=0;\r
+       Option::Instance()->GetInt("MaxMessageRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
@@ -335,8 +336,9 @@ void MessageRequester::Initialize()
        {\r
                m_log->warning("Option MaxMessageRequests is currently set at "+tempval+".  This value might be incorrectly configured.");\r
        }\r
-       Option::Instance()->Get("MessageDownloadMaxDaysBackward",tempval);\r
-       StringFunctions::Convert(tempval,m_maxdaysbackward);\r
+\r
+       m_maxdaysbackward=0;\r
+       Option::Instance()->GetInt("MessageDownloadMaxDaysBackward",m_maxdaysbackward);\r
        if(m_maxdaysbackward<0)\r
        {\r
                m_maxdaysbackward=0;\r
@@ -346,8 +348,9 @@ void MessageRequester::Initialize()
        {\r
                m_log->warning("Option MessageDownloadMaxDaysBackward is currently set at "+tempval+".  This value might be incorrectly configured.");\r
        }\r
-       Option::Instance()->Get("MaxPeerMessagesPerDay",tempval);\r
-       StringFunctions::Convert(tempval,m_maxpeermessages);\r
+\r
+       m_maxpeermessages=0;\r
+       Option::Instance()->GetInt("MaxPeerMessagesPerDay",m_maxpeermessages);\r
        if(m_maxpeermessages<1)\r
        {\r
                m_maxpeermessages=1;\r
@@ -357,8 +360,9 @@ void MessageRequester::Initialize()
        {\r
                m_log->warning("Option MaxPeerMessagesPerDay is currently set at "+tempval+".  This value might be incorrectly configured.  The suggested value is 200.");\r
        }\r
-       Option::Instance()->Get("MaxBoardsPerMessage",tempval);\r
-       StringFunctions::Convert(tempval,m_maxboardspermessage);\r
+\r
+       m_maxboardspermessage=0;\r
+       Option::Instance()->GetInt("MaxBoardsPerMessage",m_maxboardspermessage);\r
        if(m_maxboardspermessage<1)\r
        {\r
                m_maxboardspermessage=1;\r
index be6bfc1..78ec556 100644 (file)
@@ -270,8 +270,9 @@ void TrustListRequester::Initialize()
 {\r
        std::string tempval="";\r
        m_fcpuniquename="TrustListRequester";\r
-       Option::Instance()->Get("MaxIdentityRequests",tempval);\r
-       StringFunctions::Convert(tempval,m_maxrequests);\r
+\r
+       m_maxrequests=0;\r
+       Option::Instance()->GetInt("MaxIdentityRequests",m_maxrequests);\r
        if(m_maxrequests<1)\r
        {\r
                m_maxrequests=1;\r
index 6e53237..84d07ff 100644 (file)
@@ -1323,6 +1323,14 @@ void NNTPConnection::run()
                        m_log->error("NNTPConnection::run select returned -1 : "+GetSocketErrorMessage());      \r
                }\r
 \r
+               //process all remaining commands in buffer\r
+               std::vector<char>::size_type rbs=0;\r
+               while(rbs!=m_receivebuffer.size())\r
+               {\r
+                       rbs=m_receivebuffer.size();\r
+                       HandleReceivedData();\r
+               }\r
+\r
        }while(!Disconnected() && !IsCancelled());\r
 \r
        Disconnect();\r
index b79e90c..9694a45 100644 (file)
@@ -20,3 +20,24 @@ const bool Option::Get(const std::string &option, std::string &value)
                return false;\r
        }\r
 }\r
+\r
+const bool Option::GetInt(const std::string &option, int &value)\r
+{\r
+       std::string valstr="";\r
+       if(Get(option,valstr))\r
+       {\r
+               std::istringstream istr(valstr);\r
+               if(istr >> value)\r
+               {\r
+                       return true;\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r