From 7ec2d1c53b753238509bf7a89587509305b9216d Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sun, 19 Oct 2008 20:06:14 +0000 Subject: move to asio socket libary for sync bugs / todos: * new connections don't sync * anyrtpproxy broken * anytun-controlld doesn't send data --- src/anytun-controld.cpp | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src/anytun-controld.cpp') diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index 4f59743..2593a2b 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -42,9 +42,10 @@ #include "signalController.h" #include "anyCtrOptions.h" -#include "anyCtrSocket.h" -#include "Sockets/ListenSocket.h" -#include "Sockets/SocketHandler.h" +#include "syncServer.h" +//#include "anyCtrSocket.h" +//#include "Sockets/ListenSocket.h" +//#include "Sockets/SocketHandler.h" class ThreadParam @@ -55,22 +56,21 @@ public: u_int16_t port; }; - -void* syncListener(void* p ) +void syncListener(void* p ) { ThreadParam* param = reinterpret_cast(p); - SOCKETS_NAMESPACE::SocketHandler h; - SOCKETS_NAMESPACE::ListenSocket l(h,true); - if( l.Bind(param->addr, param->port) ) - pthread_exit(NULL); + try + { + asio::io_service io_service; + SyncServer server(io_service,asio::ip::tcp::endpoint(asio::ip::tcp::v4(), param->port)); + io_service.run(); + } + catch (std::exception& e) + { + std::cerr << e.what() << std::endl; + } - Utility::ResolveLocal(); // resolve local hostname - h.Add(&l); - h.Select(1,0); - while (1) { - h.Select(1,0); - } } void chrootAndDrop(std::string const& chrootdir, std::string const& username) @@ -168,14 +168,18 @@ int main(int argc, char* argv[]) ThreadParam p; p.addr = gOpt.getBindToAddr(); p.port = gOpt.getBindToPort(); - pthread_t syncListenerThread; - pthread_create(&syncListenerThread, NULL, syncListener, &p); + boost::thread * syncListenerThread; + syncListenerThread = new boost::thread(boost::bind(syncListener,&p)); + + syncListener(&p); +// pthread_t syncListenerThread; +// pthread_create(&syncListenerThread, NULL, syncListener, &p); int ret = sig.run(); - pthread_cancel(syncListenerThread); +// pthread_cancel(syncListenerThread); - pthread_join(syncListenerThread, NULL); +// pthread_join(syncListenerThread, NULL); return ret; } -- cgit v1.2.3