diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-09-29 15:40:49 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-09-29 15:40:49 +0200 |
commit | f7aa3f9bd315ba52d6ee1e7236a580102c8d20b8 (patch) | |
tree | 45d4adcd35e59ec11233d1f6a65b78fad811701f /vncviewer/vncviewer.cxx | |
parent | 7ebce759122eeda383d7d299ee577c75c0f9ac6e (diff) | |
download | tigervnc-f7aa3f9bd315ba52d6ee1e7236a580102c8d20b8.tar.gz tigervnc-f7aa3f9bd315ba52d6ee1e7236a580102c8d20b8.zip |
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.
Diffstat (limited to 'vncviewer/vncviewer.cxx')
-rw-r--r-- | vncviewer/vncviewer.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 230cc25a..a2bc0297 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -525,7 +525,7 @@ int main(int argc, char** argv) #endif if (listenMode) { - std::list<TcpListener> listeners; + std::list<TcpListener*> listeners; try { int port = 5500; if (isdigit(vncServerName[0])) @@ -539,10 +539,10 @@ int main(int argc, char** argv) while (sock == NULL) { fd_set rfds; FD_ZERO(&rfds); - for (std::list<TcpListener>::iterator i = listeners.begin(); + for (std::list<TcpListener*>::iterator i = listeners.begin(); i != listeners.end(); i++) - FD_SET((*i).getFd(), &rfds); + FD_SET((*i)->getFd(), &rfds); int n = select(FD_SETSIZE, &rfds, 0, 0, 0); if (n < 0) { @@ -554,11 +554,11 @@ int main(int argc, char** argv) } } - for (std::list<TcpListener>::iterator i = listeners.begin (); + for (std::list<TcpListener*>::iterator i = listeners.begin (); i != listeners.end(); i++) - if (FD_ISSET((*i).getFd(), &rfds)) { - sock = (*i).accept(); + if (FD_ISSET((*i)->getFd(), &rfds)) { + sock = (*i)->accept(); if (sock) /* Got a connection */ break; @@ -571,6 +571,10 @@ int main(int argc, char** argv) return 1; } + while (!listeners.empty()) { + delete listeners.back(); + listeners.pop_back(); + } } else { if (vncServerName[0] == '\0') { ServerDialog::run(defaultServerName, vncServerName); |