version 0.1.4
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Thu, 31 Jan 2008 14:10:00 +0000 (15:10 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 31 Jan 2008 14:10:00 +0000 (15:10 +0100)
15 files changed:
CMakeLists.txt
admin/identitytrust.php
admin/introduce.php
include/commandthread.h
include/db/sqlite3db/sqlite3db.h
include/db/sqlite3db/sqlite3statement.h
include/global.h
include/pthreadwrapper/deadlockexception.h [new file with mode: 0644]
include/pthreadwrapper/mutex.h
include/pthreadwrapper/runnable.h
src/db/sqlite3statement.cpp
src/freenet/freenetmasterthread.cpp
src/freenet/identityintroductioninserter.cpp
src/global.cpp
src/pthreadwrapper/mutex.cpp

index 4e06722..18a089c 100644 (file)
@@ -84,6 +84,9 @@ ELSE(SQLITE3_LIBRARY)
        ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
        TARGET_LINK_LIBRARIES(fms sqlite3)\r
        INCLUDE_DIRECTORIES(libs/sqlite3)\r
+       IF(CMAKE_COMPILER_IS_GNUCC)\r
+               TARGET_LINK_LIBRARIES(fms dl)\r
+       ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
 ENDIF(SQLITE3_LIBRARY)\r
 \r
 IF(TINYXML_LIBRARY)\r
index 6c4663b..bdc4718 100644 (file)
@@ -46,14 +46,22 @@ function content()
                ?>\r
                <tr>\r
                        <td title="<?php print($record[6]); ?>">\r
-                               <?php print($record[1]); ?>\r
+                               <?php \r
+                                       print($record[1]);\r
+                                       if($record[1]=='')\r
+                                       {\r
+                                               print("[Unknown Name]");        \r
+                                       }\r
+                               ?>\r
                                <input type="hidden" name="identityid[]" value="<?php print($record[0]); ?>">\r
                        </td>\r
                        <td>\r
                                <input type="hidden" name="oldlocalmessagetrust[]" value="<?php print($record[2]); ?>">\r
                                <input type="text" name="newlocalmessagetrust[]" size="2" maxlength="3" value="<?php print($record[2]); ?>">\r
                        </td>\r
-                       <td><?php print($record[3]); ?></td>\r
+                       <td>\r
+                               <?php print($record[3]); ?>\r
+                       </td>\r
                        <td>\r
                                <input type="hidden" name="oldlocaltrustlisttrust[]" value="<?php print($record[4]); ?>">\r
                                <input type="text" name="newlocaltrustlisttrust[]" size="2" maxlength="3" value="<?php print($record[4]); ?>">\r
index b13a05e..216809d 100644 (file)
@@ -53,7 +53,7 @@ function content()
        print "<br>Type answers for a few puzzles and submit<br>";\r
        \r
        \r
-       $st=$db->prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
+       $st=$db->prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
        $st->execute();\r
        \r
        // only show latest captcha for each known identity\r
index 58a7129..166482c 100644 (file)
@@ -5,7 +5,7 @@
 #include "idatabase.h"\r
 \r
 //#include <zthread/Thread.h>\r
-#include "pthreadwrapper.h"\r
+#include "pthreadwrapper/runnable.h"\r
 \r
 class CommandThread:public PThread::Runnable,public ILogger, public IDatabase\r
 {\r
index 91bdfec..f0aac60 100644 (file)
 \r
 #include "../sqlite3db.h"\r
 \r
+#if SQLITE_VERSION_NUMBER<3005000\r
+#error "Your version of SQLite is too old!  3.5.0 or later is required."\r
+#endif\r
+\r
 namespace SQLite3DB\r
 {\r
 \r
index 6294c8e..04b24a0 100644 (file)
@@ -57,7 +57,8 @@ private:
        long m_lastinsertrowid;\r
 \r
        static std::map<sqlite3_stmt *, long> m_statementcount;\r
-       std::vector<char *> textptrs;\r
+       //std::vector<char *> textptrs;\r
+       std::vector<std::vector<char>> m_boundtext;\r
 \r
 };     //class\r
 \r
index 167c3e0..b2df48f 100644 (file)
@@ -5,7 +5,7 @@
 //#include <zthread/Thread.h>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.1.3"\r
+#define FMS_VERSION    "0.1.4"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
diff --git a/include/pthreadwrapper/deadlockexception.h b/include/pthreadwrapper/deadlockexception.h
new file mode 100644 (file)
index 0000000..3f83736
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _pthread_wrapper_\r
+#define _pthread_wrapper_\r
+\r
+#include <exception>\r
+\r
+namespace PThread\r
+{\r
+       \r
+class DeadlockException:public std::exception\r
+{\r
+public:\r
+       const char *what() const        { return "Deadlock Exception"; }\r
+};\r
+       \r
+}      // namespace\r
+\r
+#endif // _pthread_wrapper_\r
index 44e9085..7a4fb9d 100644 (file)
@@ -2,7 +2,7 @@
 #define _pthread_mutex_\r
 \r
 #include <pthread.h>\r
-#include <exception>\r
+#include "deadlockexception.h"\r
 \r
 namespace PThread\r
 {\r
index 7906f19..cc3900e 100644 (file)
@@ -22,7 +22,7 @@ protected:
 \r
 private:\r
 \r
-       friend Thread;\r
+       friend class Thread;\r
        Thread *m_thread;\r
 \r
 };\r
index 54c26fe..538ed06 100644 (file)
@@ -44,6 +44,7 @@ Statement::~Statement()
        \r
        Finalize();\r
        \r
+       /*\r
        std::vector<char *>::iterator i;\r
        for(i=textptrs.begin(); i!=textptrs.end(); i++)\r
        {\r
@@ -52,6 +53,7 @@ Statement::~Statement()
                        delete [] (*i);\r
                }\r
        }\r
+       */\r
 }\r
 \r
 const bool Statement::Bind(const int column)\r
@@ -121,13 +123,16 @@ const bool Statement::Bind(const int column, const std::string &value)
 {\r
        if(Valid() && column>=0 && column<m_parametercount)\r
        {\r
-               char *text=new char[value.size()+1];\r
-               strncpy(text,value.c_str(),value.size());\r
-               text[value.size()]=NULL;\r
-               textptrs.push_back(text);\r
+               //char *text=new char[value.size()+1];\r
+               //strncpy(text,value.c_str(),value.size());\r
+               //text[value.size()]=NULL;\r
+               //textptrs.push_back(text);\r
+               \r
                //ZThread::Guard<ZThread::Mutex> g(DB::instance()->m_mutex);\r
                PThread::Guard g(DB::Instance()->m_mutex);\r
-               if(sqlite3_bind_text(m_statement,column+1,text,value.size(),NULL)==SQLITE_OK)\r
+               m_boundtext.push_back(std::vector<char>(value.begin(),value.end()));\r
+               //if(sqlite3_bind_text(m_statement,column+1,text,value.size(),NULL)==SQLITE_OK)\r
+               if(sqlite3_bind_text(m_statement,column+1,&m_boundtext[m_boundtext.size()-1][0],m_boundtext[m_boundtext.size()-1].size(),NULL)==SQLITE_OK)              \r
                {\r
                        return true;\r
                }\r
index 398d8fa..cca101c 100644 (file)
@@ -194,7 +194,7 @@ void FreenetMasterThread::Run()
                                        done=true;\r
                                }\r
                                */\r
-                               for(int i=0; i<60,!IsCancelled(); i++)\r
+                               for(int i=0; i<60 && !IsCancelled(); i++)\r
                                {\r
                                        Sleep(1000);\r
                                }\r
index 3c1fe5f..05fe782 100644 (file)
@@ -61,6 +61,8 @@ const bool IdentityIntroductionInserter::HandleMessage(FCPMessage &message)
                        if(message["Fatal"]=="true" || message["Code"]=="9")\r
                        {\r
                                m_db->Execute("DELETE FROM tblIdentityIntroductionInserts WHERE UUID='"+idparts[3]+"';");\r
+                               // update the puzzle from the request table (set to not found) because we don't need it anymore and don't want to user tyring to solve it again\r
+                               m_db->Execute("UPDATE tblIntroductionPuzzleRequests SET Found='false' WHERE UUID='"+idparts[3]+"';");\r
                                m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"IdentityIntroductionInserter::HandleMessage received fatal error trying to insert IdentityIntroduction "+idparts[3]);\r
                        }\r
                        m_inserting=false;\r
index 8552db2..d4cc101 100644 (file)
@@ -290,7 +290,7 @@ void SetupDB()
 \r
        // insert SomeDude's public key\r
        date.SetToGMTime();\r
-//     db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+       //db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
 \r
 }\r
 \r
index ca554b1..aec6561 100644 (file)
@@ -1,6 +1,10 @@
 #include "../../include/pthreadwrapper/mutex.h"\r
 #include <exception>\r
 \r
+#ifndef _WIN32\r
+       #include <sys/errno.h>\r
+#endif\r
+\r
 #ifdef XMEM\r
        #include <xmem.h>\r
 #endif\r
@@ -29,7 +33,7 @@ void Mutex::Acquire() throw(std::exception)
                // deadlock - throw exception\r
                if(rval==EDEADLK)\r
                {\r
-                       throw std::exception("Mutex would deadlock!");\r
+                       throw DeadlockException();\r
                }\r
        }\r
 }\r