summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-15 02:20:05 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-15 02:20:05 +0000
commit6c359a35146d9b728fab8c8d8220aa340abfd89d (patch)
tree4cea9381f27f0933d18d6c1ed63b507b747a9bd5
parentremoved useless file (diff)
small cleanup
-rw-r--r--src/anytun.cpp24
-rw-r--r--src/connectionList.cpp14
2 files changed, 20 insertions, 18 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index 3949187..bbea08a 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -79,13 +79,13 @@
void createConnection(const PacketSourceEndpoint & remote_end, window_size_t seqSize, mux_t mux)
{
- SeqWindow * seq= new SeqWindow(seqSize);
+ SeqWindow* seq = new SeqWindow(seqSize);
seq_nr_t seq_nr_=0;
KeyDerivation * kd = KeyDerivationFactory::create(gOpt.getKdPrf());
kd->init(gOpt.getKey(), gOpt.getSalt());
cLog.msg(Log::PRIO_NOTICE) << "added connection remote host " << remote_end;
- ConnectionParam connparam ( (*kd), (*seq), seq_nr_, remote_end);
+ ConnectionParam connparam ((*kd), (*seq), seq_nr_, remote_end);
gConnectionList.addConnection(connparam,mux);
#ifndef ANYTUN_NOSYNC
SyncCommand sc (gConnectionList,mux);
@@ -411,8 +411,9 @@ int main(int argc, char* argv[])
SignalController sig;
sig.init();
#endif
-
- ThreadParam p(dev, *src, *(new OptionConnectTo()));
+
+ OptionConnectTo* connTo = new OptionConnectTo();
+ ThreadParam p(dev, *src, *connTo);
#ifndef NOCRYPT
#ifndef USE_SSL_CRYPTO
@@ -440,11 +441,10 @@ int main(int argc, char* argv[])
#ifndef NOSIGNALCONTROLLER
int ret = sig.run();
- return ret;
#else
- receiver(&p);
+ receiver(&p);
#endif
- // TODO cleanup here!
+ // TODO cleanup threads here!
/*
pthread_cancel(senderThread);
pthread_cancel(receiverThread);
@@ -464,11 +464,13 @@ int main(int argc, char* argv[])
for( std::list<pthread_t>::iterator it = connectThreads.begin() ;it != connectThreads.end(); ++it)
pthread_join(*it, NULL);
#endif
- delete src;
- delete &p.connto;
-
- return ret;
+ if(src)
+ delete src;
+ if(connTo)
+ delete connTo;
*/
+
+ return ret;
}
catch(std::runtime_error& e)
{
diff --git a/src/connectionList.cpp b/src/connectionList.cpp
index a0d4abf..d6b373f 100644
--- a/src/connectionList.cpp
+++ b/src/connectionList.cpp
@@ -58,13 +58,13 @@ ConnectionList::ConnectionList()
ConnectionList::~ConnectionList()
{
-/* Lock lock(mutex_);
- ConnectionMap::iterator it;
- for(it = connections_.begin(); it != connections_.end(); ++it)
- {
- //delete &it->second.kd_;
- }
-*/
+// TODO: comment this in as soon as threads @ main get cleaned up properly
+// Lock lock(mutex_);
+// ConnectionMap::iterator it;
+// for(it = connections_.begin(); it != connections_.end(); ++it) {
+// delete &it->second.kd_;
+// delete &it->second.seq_window_;
+// }
}
void ConnectionList::addConnection(ConnectionParam &conn, u_int16_t mux )