diff options
-rw-r--r-- | anytun.cpp | 7 | ||||
-rw-r--r-- | connectionParam.cpp | 2 | ||||
-rw-r--r-- | connectionParam.h | 4 | ||||
-rw-r--r-- | keyDerivation.h | 1 | ||||
-rw-r--r-- | seqWindow.h | 8 | ||||
-rw-r--r-- | syncBuffer.h | 4 | ||||
-rw-r--r-- | syncCommand.h | 4 |
7 files changed, 24 insertions, 6 deletions
@@ -89,7 +89,8 @@ void createConnection(const std::string & remote_host , u_int16_t remote_port, C cLog.msg(Log::PRIO_NOTICE) << "added connection remote host " << remote_host << ":" << remote_port; ConnectionParam connparam ( (*kd), (*seq), seq_nr_, remote_host, remote_port); cl.addConnection(connparam,0); - queue.push(SyncCommand(cl,0)); + SyncCommand sc (cl,0); + queue.push(sc); } @@ -257,7 +258,8 @@ void* receiver(void* p) cLog.msg(Log::PRIO_NOTICE) << "autodetected remote host ip changed " << remote_host << ":" << remote_port; conn.remote_host_=remote_host; conn.remote_port_=remote_port; - param->queue.push(SyncCommand(param->cl,0)); + SyncCommand sc (param->cl,0); + param->queue.push(sc); } // Replay Protection @@ -361,6 +363,7 @@ int main(int argc, char* argv[]) pthread_join(*it, NULL); delete src; + delete &p.connto; return ret; } diff --git a/connectionParam.cpp b/connectionParam.cpp index 6c03f61..3f4b880 100644 --- a/connectionParam.cpp +++ b/connectionParam.cpp @@ -38,6 +38,6 @@ ConnectionParam::ConnectionParam(KeyDerivation& kd, SeqWindow& seq_window,seq_nr { } -ConnectionParam::ConnectionParam(const ConnectionParam & src) : kd_(src.kd_),seq_window_(src.seq_window_),seq_nr_(src.seq_nr_),remote_host_(src.remote_host_), remote_port_(src.remote_port_) +ConnectionParam::ConnectionParam(const ConnectionParam & src) : kd_(src.kd_),seq_window_(src.seq_window_),seq_nr_(src.seq_nr_),remote_host_(src.remote_host_), remote_port_(src.remote_port_),mutex_() { } diff --git a/connectionParam.h b/connectionParam.h index cf8df3b..5e00e25 100644 --- a/connectionParam.h +++ b/connectionParam.h @@ -36,6 +36,7 @@ #include "cypher.h" #include "authAlgo.h" #include "seqWindow.h" +#include "threadUtils.hpp" #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> @@ -51,10 +52,13 @@ public: u_int16_t remote_port_; ConnectionParam(const ConnectionParam & src); private: +//TODO check if this is ok + Mutex mutex_; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { + Lock lock(mutex_); ar & kd_; ar & seq_window_; ar & seq_nr_; diff --git a/keyDerivation.h b/keyDerivation.h index 56ca748..531d441 100644 --- a/keyDerivation.h +++ b/keyDerivation.h @@ -66,6 +66,7 @@ private: template<class Archive> void serialize(Archive & ar, const unsigned int version) { + Lock lock(mutex_); ar & ld_kdr_; ar & salt_; } diff --git a/seqWindow.h b/seqWindow.h index f2ad347..3a629ee 100644 --- a/seqWindow.h +++ b/seqWindow.h @@ -55,6 +55,10 @@ public: private: + window_size_t window_size_; + Mutex mutex_; + SenderMap sender_; + SeqWindow(const SeqWindow &s); void operator=(const SeqWindow &s); @@ -62,6 +66,7 @@ private: template<class Archive> void serialize(Archive & ar, const unsigned int version) { + Lock lock(mutex_); //unsigned int serial = (unsigned int) window_size_; //window_size_t serial = (window_size_t) window_size_; ar & window_size_; @@ -70,9 +75,6 @@ private: } - window_size_t window_size_; - Mutex mutex_; - SenderMap sender_; }; #endif diff --git a/syncBuffer.h b/syncBuffer.h index 1bae2a3..3fdca05 100644 --- a/syncBuffer.h +++ b/syncBuffer.h @@ -36,6 +36,7 @@ #include "buffer.h" #include <iostream> #include "datatypes.h" +#include "threadUtils.hpp" class SyncBuffer : public Buffer { @@ -46,10 +47,13 @@ public: SyncBuffer(u_int8_t* data, u_int32_t length): Buffer(data,length) {}; SyncBuffer(const SyncBuffer & src) : Buffer(src) {}; private: +//TODO check if this is ok +// Mutex mutex_; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { +// Lock lock(mutex_); ar & length_; for(u_int32_t i = 0; i < length_; i++) ar & (*this)[i]; diff --git a/syncCommand.h b/syncCommand.h index 6e1e3ea..c556cfb 100644 --- a/syncCommand.h +++ b/syncCommand.h @@ -4,6 +4,7 @@ #include <boost/archive/text_iarchive.hpp> #include "connectionList.h" +#include "threadUtils.hpp" class SyncCommand { @@ -13,12 +14,15 @@ public: u_int16_t getMux() const; private: + SyncCommand(const SyncCommand &); + ::Mutex mutex_; ConnectionList & cl_; u_int16_t mux_; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { + Lock lock(mutex_); ar & mux_; ConnectionParam & conn = cl_.getOrNewConnection(mux_); ar & conn; |