From f7aa3f9bd315ba52d6ee1e7236a580102c8d20b8 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 29 Sep 2015 15:40:49 +0200 Subject: Return TcpListener pointers rather than objects It is easier to control object life time and avoid magical socket duplication by having a single TcpListener object to pass around. We have to be more careful about deleting the object though. --- win/winvnc/ManagedListener.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'win/winvnc/ManagedListener.cxx') diff --git a/win/winvnc/ManagedListener.cxx b/win/winvnc/ManagedListener.cxx index 25d8dc0f..b80f5a16 100644 --- a/win/winvnc/ManagedListener.cxx +++ b/win/winvnc/ManagedListener.cxx @@ -31,9 +31,9 @@ ManagedListener::ManagedListener(SocketManager* mgr) ManagedListener::~ManagedListener() { if (!sockets.empty()) { - std::list::iterator iter; + std::list::iterator iter; for (iter = sockets.begin(); iter != sockets.end(); ++iter) - manager->remListener(&*iter); + manager->remListener(*iter); sockets.clear(); } delete filter; @@ -62,9 +62,9 @@ void ManagedListener::setFilter(const char* filterStr) { delete filter; filter = new network::TcpFilter(filterStr); if (!sockets.empty() && !localOnly) { - std::list::iterator iter; + std::list::iterator iter; for (iter = sockets.begin(); iter != sockets.end(); ++iter) - iter->setFilter(filter); + (*iter)->setFilter(filter); } } @@ -80,10 +80,10 @@ bool ManagedListener::isListening() { } void ManagedListener::refresh() { - std::list::iterator iter; + std::list::iterator iter; if (!sockets.empty()) { for (iter = sockets.begin(); iter != sockets.end(); ++iter) - manager->remListener(&*iter); + manager->remListener(*iter); sockets.clear(); } if (!server) @@ -101,11 +101,11 @@ void ManagedListener::refresh() { if (!sockets.empty()) { if (!localOnly) { for (iter = sockets.begin(); iter != sockets.end(); ++iter) - iter->setFilter(filter); + (*iter)->setFilter(filter); } try { for (iter = sockets.begin(); iter != sockets.end(); ++iter) - manager->addListener(&*iter, server, addrChangeNotifier); + manager->addListener(*iter, server, addrChangeNotifier); } catch (...) { // FIXME: Should unwind what we've added sockets.clear(); -- cgit v1.2.3