summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anytun.cpp8
-rw-r--r--connectionList.cpp4
-rw-r--r--connectionList.h2
-rw-r--r--syncCommand.h3
-rw-r--r--syncQueue.cpp5
5 files changed, 13 insertions, 9 deletions
diff --git a/anytun.cpp b/anytun.cpp
index 0e7b01b..2056f02 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -87,11 +87,10 @@ void createConnection(const std::string & remote_host , u_int16_t remote_port, C
KeyDerivation * kd = new KeyDerivation;
kd->init(Buffer(key, sizeof(key)), Buffer(salt, sizeof(salt)));
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);
+ SyncCommand sc (cl,0);
- cl.addConnection(connparam,0);
- SyncCommand sc (cl,0);
queue.push(sc);
}
@@ -361,9 +360,12 @@ int main(int argc, char* argv[])
ConnectToList connect_to = opt.getConnectTo();
SyncQueue queue;
+ cLog.msg(Log::PRIO_DEBUG) << "pre create conn";
+
if(opt.getRemoteAddr() != "")
createConnection(opt.getRemoteAddr(),opt.getRemotePort(),cl,opt.getSeqWindowSize(), queue);
+ cLog.msg(Log::PRIO_DEBUG) << "post create conn";
ThreadParam p(opt, dev, *src, cl, queue,*(new OptionConnectTo()));
diff --git a/connectionList.cpp b/connectionList.cpp
index f4d9cde..de863eb 100644
--- a/connectionList.cpp
+++ b/connectionList.cpp
@@ -66,10 +66,8 @@ const ConnectionMap::iterator ConnectionList::getConnection(u_int16_t mux)
}
-ConnectionParam & ConnectionList::getOrNewConnection(u_int16_t mux)
+ConnectionParam & ConnectionList::getOrNewConnectionUnlocked(u_int16_t mux)
{
- Lock lock(mutex_);
-
ConnectionMap::iterator it = connections_.find(mux);
if(it!=connections_.end())
return it->second;
diff --git a/connectionList.h b/connectionList.h
index 6cd24b4..98f7799 100644
--- a/connectionList.h
+++ b/connectionList.h
@@ -48,7 +48,7 @@ public:
void addConnection(ConnectionParam &conn, u_int16_t mux);
const ConnectionMap::iterator getConnection(u_int16_t mux);
const ConnectionMap::iterator getEnd();
- ConnectionParam & getOrNewConnection(u_int16_t mux);
+ ConnectionParam & getOrNewConnectionUnlocked(u_int16_t mux);
bool empty();
void clear();
Mutex& getMutex();
diff --git a/syncCommand.h b/syncCommand.h
index e8f66a7..b2f3fc5 100644
--- a/syncCommand.h
+++ b/syncCommand.h
@@ -15,7 +15,6 @@ public:
private:
SyncCommand(const SyncCommand &);
- ::Mutex mutex_;
ConnectionList & cl_;
u_int16_t mux_;
friend class boost::serialization::access;
@@ -24,7 +23,7 @@ private:
{
Lock lock(cl_.getMutex());
ar & mux_;
- ConnectionParam & conn = cl_.getOrNewConnection(mux_);
+ ConnectionParam & conn = cl_.getOrNewConnectionUnlocked(mux_);
ar & conn;
}
};
diff --git a/syncQueue.cpp b/syncQueue.cpp
index 7d3c35f..81c8a0e 100644
--- a/syncQueue.cpp
+++ b/syncQueue.cpp
@@ -42,10 +42,15 @@
#include "syncQueue.h"
void SyncQueue::push(const SyncCommand & scom )
{
+
+ std::cout << "entered push" << std::endl;
+
std::ostringstream sout;
boost::archive::text_oarchive oa(sout);
oa << scom;
+ std::cout << "after serialize" << std::endl;
+
Lock lock(mutex_);
queue_.push(sout.str());
}