From: SomeDude Date: Tue, 29 Jan 2008 16:41:00 +0000 (+0100) Subject: version 0.1.3 X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=commitdiff_plain;h=c7fcb4c4bc5012a584add81a9509fc1f84c3c688 version 0.1.3 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index be285e2..4e06722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,26 +53,29 @@ src/nntp/mime/Mime.cpp src/nntp/mime/MimeChar.cpp src/nntp/mime/MimeCode.cpp src/nntp/mime/MimeType.cpp +src/pthreadwrapper/guard.cpp +src/pthreadwrapper/mutex.cpp +src/pthreadwrapper/runnable.cpp +src/pthreadwrapper/thread.cpp src/xyssl/sha1.c ) ADD_DEFINITIONS(-DTIXML_USE_STL) -IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +IF(CMAKE_COMPILER_IS_GNUCXX) ADD_DEFINITIONS(-fpermissive) -ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) ADD_EXECUTABLE(fms ${FMS_SRC}) -INCLUDE_DIRECTORIES(libs/sqlite3 libs/tinyxml) - IF(WIN32) TARGET_LINK_LIBRARIES(fms ws2_32) ENDIF(WIN32) FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s) FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s) -FIND_LIBRARY(ZTHREADS_LIBRARY NAMES zthread ZThread zthread_s) +#FIND_LIBRARY(ZTHREADS_LIBRARY NAMES zthread ZThread zthread_s) +FIND_LIBRARY(PTHREADS_LIBRARY NAMES pthread pthreads pthreadvc2) IF(SQLITE3_LIBRARY) TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY}) @@ -80,8 +83,7 @@ ELSE(SQLITE3_LIBRARY) MESSAGE(STATUS "Could not find system SQLite library. Will compile from included source.") ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c) TARGET_LINK_LIBRARIES(fms sqlite3) -ADD_LIBRARY(tinyxml libs/tinyxml/tinystr.cpp libs/tinyxml/tinyxml.cpp libs/tinyxml/tinyxmlerror.cpp libs/tinyxml/tinyxmlparser.cpp) - + INCLUDE_DIRECTORIES(libs/sqlite3) ENDIF(SQLITE3_LIBRARY) IF(TINYXML_LIBRARY) @@ -90,10 +92,17 @@ ELSE(TINYXML_LIBRARY) MESSAGE(STATUS "Could not find system TinyXML library. Will compile from included source.") ADD_LIBRARY(tinyxml libs/tinyxml/tinystr.cpp libs/tinyxml/tinyxml.cpp libs/tinyxml/tinyxmlerror.cpp libs/tinyxml/tinyxmlparser.cpp) TARGET_LINK_LIBRARIES(fms tinyxml) + INCLUDE_DIRECTORIES(libs/tinyxml) ENDIF(TINYXML_LIBRARY) -IF(ZTHREADS_LIBRARY) - TARGET_LINK_LIBRARIES(fms ${ZTHREADS_LIBRARY}) -ELSE(ZTHREADS_LIBRARY) - MESSAGE(FATAL_ERROR "Could not find ZThreads library. You must set the location manually.") -ENDIF(ZTHREADS_LIBRARY) +#IF(ZTHREADS_LIBRARY) +# TARGET_LINK_LIBRARIES(fms ${ZTHREADS_LIBRARY}) +#ELSE(ZTHREADS_LIBRARY) +# MESSAGE(FATAL_ERROR "Could not find ZThreads library. You must set the location manually.") +#ENDIF(ZTHREADS_LIBRARY) + +IF(PTHREADS_LIBRARY) + TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY}) +ELSE(PTHREADS_LIBRARY) + MESSAGE(FATAL ERROR "Could not find pthreads library. You must set the location manually.") +ENDIF(PTHREADS_LIBRARY) diff --git a/include/commandthread.h b/include/commandthread.h index 0d51366..58a7129 100644 --- a/include/commandthread.h +++ b/include/commandthread.h @@ -4,13 +4,14 @@ #include "ilogger.h" #include "idatabase.h" -#include +//#include +#include "pthreadwrapper.h" -class CommandThread:public ZThread::Runnable,public ILogger, public IDatabase +class CommandThread:public PThread::Runnable,public ILogger, public IDatabase { public: - void run(); + void Run(); private: diff --git a/include/db/sqlite3db/sqlite3db.h b/include/db/sqlite3db/sqlite3db.h index 24c4a3a..91bdfec 100644 --- a/include/db/sqlite3db/sqlite3db.h +++ b/include/db/sqlite3db/sqlite3db.h @@ -1,17 +1,19 @@ #ifndef _sqlite3db_ #define _sqlite3db_ -#include -#include +//#include +//#include #include #include +#include "../../pthreadwrapper/singleton.h" +#include "../../pthreadwrapper/mutex.h" #include "../sqlite3db.h" namespace SQLite3DB { -class DB:public ZThread::Singleton +class DB:public PThread::Singleton { public: DB(); @@ -35,7 +37,7 @@ public: sqlite3 *GetDB() { return m_db; } - ZThread::Mutex m_mutex; // public so that recordset and statment can lock this mutex themselves + PThread::Mutex m_mutex; // public so that recordset and statment can lock this mutex themselves private: void Initialize(); diff --git a/include/freenet/freenetmasterthread.h b/include/freenet/freenetmasterthread.h index f84acc1..e1f2453 100644 --- a/include/freenet/freenetmasterthread.h +++ b/include/freenet/freenetmasterthread.h @@ -7,12 +7,13 @@ #include "ifcpconnected.h" #include "iperiodicprocessor.h" -#include +//#include +#include "../pthreadwrapper/runnable.h" // forward declaration class IFreenetRegistrable; -class FreenetMasterThread:public ZThread::Runnable,public ILogger, public IFCPMessageHandler +class FreenetMasterThread:public PThread::Runnable,public ILogger, public IFCPMessageHandler { public: FreenetMasterThread(); @@ -20,7 +21,7 @@ public: const bool HandleMessage(FCPMessage &message); - void run(); + void Run(); // registration methods for children objects void RegisterPeriodicProcessor(IPeriodicProcessor *obj); diff --git a/include/freenet/iindexinserter.h b/include/freenet/iindexinserter.h index ccf1cd5..fc1a6bc 100644 --- a/include/freenet/iindexinserter.h +++ b/include/freenet/iindexinserter.h @@ -117,7 +117,7 @@ template void IIndexInserter::InitializeIIndexInserter() { m_fcpuniquename=""; - Option::instance()->Get("MessageBase",m_messagebase); + Option::Instance()->Get("MessageBase",m_messagebase); m_lastchecked.SetToGMTime(); } diff --git a/include/freenet/iindexrequester.h b/include/freenet/iindexrequester.h index 8f9e4e5..eeb8ccf 100644 --- a/include/freenet/iindexrequester.h +++ b/include/freenet/iindexrequester.h @@ -127,7 +127,7 @@ void IIndexRequester::InitializeIIndexRequester() m_maxrequests=-1; m_fcpuniquename=""; - Option::instance()->Get("MessageBase",m_messagebase); + Option::Instance()->Get("MessageBase",m_messagebase); m_tempdate.SetToGMTime(); } diff --git a/include/global.h b/include/global.h index 1eccbcc..167c3e0 100644 --- a/include/global.h +++ b/include/global.h @@ -2,9 +2,10 @@ #define _global_ #include -#include +//#include +#include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.1.2" +#define FMS_VERSION "0.1.3" // opens database and creates tables and initial inserts if necessary void SetupDB(); @@ -13,8 +14,8 @@ void SetupDefaultOptions(); // opens logfile and sets it up void SetupLogFile(); -void StartThreads(std::vector &threads); -void ShutdownThreads(std::vector &threads); +void StartThreads(std::vector &threads); +void ShutdownThreads(std::vector &threads); // needed for Windows to setup network void SetupNetwork(); diff --git a/include/idatabase.h b/include/idatabase.h index 6138d08..ddf9ba9 100644 --- a/include/idatabase.h +++ b/include/idatabase.h @@ -9,7 +9,7 @@ class IDatabase { public: - IDatabase():m_db(SQLite3DB::DB::instance()) {} + IDatabase():m_db(SQLite3DB::DB::Instance()) {} protected: SQLite3DB::DB *m_db; diff --git a/include/ilogger.h b/include/ilogger.h index 797c024..b03499d 100644 --- a/include/ilogger.h +++ b/include/ilogger.h @@ -9,7 +9,7 @@ class ILogger { public: - ILogger():m_log(LogFile::instance()) {} + ILogger():m_log(LogFile::Instance()) {} protected: LogFile *m_log; diff --git a/include/logfile.h b/include/logfile.h index a076d65..3008caa 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -1,10 +1,13 @@ #ifndef _logfile_ #define _logfile_ -#include -#include +//#include +//#include +#include "pthreadwrapper/singleton.h" +#include "pthreadwrapper/mutex.h" +#include -class LogFile:public ZThread::Singleton +class LogFile:public PThread::Singleton { public: LogFile(); @@ -57,7 +60,7 @@ private: bool m_writenewline; char *m_datebuffer; - ZThread::Mutex m_logmutex; + PThread::Mutex m_logmutex; }; diff --git a/include/messagelist.h b/include/messagelist.h index aa12bee..be1df9e 100644 --- a/include/messagelist.h +++ b/include/messagelist.h @@ -18,4 +18,4 @@ private: }; -#endif // _messagelist_ \ No newline at end of file +#endif // _messagelist_ diff --git a/include/nntp/mime/MimeChar.h b/include/nntp/mime/MimeChar.h index b334b00..3fc2b61 100644 --- a/include/nntp/mime/MimeChar.h +++ b/include/nntp/mime/MimeChar.h @@ -31,4 +31,4 @@ private: static const unsigned char m_aCharTbl[128]; }; -#endif // _MIME_CHAR_H \ No newline at end of file +#endif // _MIME_CHAR_H diff --git a/include/nntp/nntpconnection.h b/include/nntp/nntpconnection.h index dd365c4..64a1645 100644 --- a/include/nntp/nntpconnection.h +++ b/include/nntp/nntpconnection.h @@ -7,7 +7,8 @@ #include #include -#include +//#include +#include "../pthreadwrapper/runnable.h" #ifdef _WIN32 @@ -20,7 +21,7 @@ #include #endif -class NNTPConnection:public ZThread::Runnable,public ILogger//,public IDatabase +class NNTPConnection:public PThread::Runnable,public ILogger { public: NNTPConnection(SOCKET sock); @@ -29,7 +30,7 @@ public: void Disconnect(); const bool Disconnected() { return m_socket==INVALID_SOCKET; } - void run(); + void Run(); private: diff --git a/include/nntp/nntplistener.h b/include/nntp/nntplistener.h index 53b5d86..e109137 100644 --- a/include/nntp/nntplistener.h +++ b/include/nntp/nntplistener.h @@ -3,30 +3,32 @@ #include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +#include "../pthreadwrapper/runnable.h" #include "../socketdefines.h" /** \brief Listens for NNTP connections */ -class NNTPListener:public ZThread::Runnable +class NNTPListener:public PThread::Runnable { public: NNTPListener(); ~NNTPListener(); - void run(); + void Run(); void StartListen(); private: unsigned short m_listenport; std::vector m_listensockets; - ZThread::ThreadedExecutor m_connections; + //ZThread::ThreadedExecutor m_connections; + std::vector m_connectionthreads; }; diff --git a/include/option.h b/include/option.h index abe1a58..c18c716 100644 --- a/include/option.h +++ b/include/option.h @@ -4,10 +4,11 @@ #include "db/sqlite3db.h" #include -#include +//#include +#include "pthreadwrapper/singleton.h" //just a wrapper around the database for the options table -class Option:public ZThread::Singleton