2015-08-19 18:38:23 +00:00
|
|
|
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
|
2015-12-01 15:08:23 +00:00
|
|
|
index 5a8f75d..6ef8f2e 100644
|
2015-08-19 18:38:23 +00:00
|
|
|
--- a/common/network/TcpSocket.cxx
|
|
|
|
+++ b/common/network/TcpSocket.cxx
|
2015-12-01 15:08:23 +00:00
|
|
|
@@ -360,18 +360,12 @@ bool TcpSocket::cork(int sock, bool enable) {
|
2013-05-23 11:25:58 +00:00
|
|
|
#endif
|
|
|
|
}
|
2015-12-01 15:08:23 +00:00
|
|
|
|
2013-05-23 11:25:58 +00:00
|
|
|
-bool TcpSocket::isSocket(int sock)
|
2015-12-01 15:08:23 +00:00
|
|
|
+bool TcpSocket::isListening(int sock)
|
|
|
|
{
|
2015-08-19 18:38:23 +00:00
|
|
|
- vnc_sockaddr_t sa;
|
|
|
|
- socklen_t sa_size = sizeof(sa);
|
|
|
|
- return getsockname(sock, &sa.u.sa, &sa_size) >= 0;
|
2013-05-23 11:25:58 +00:00
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool TcpSocket::isConnected(int sock)
|
2015-12-01 15:08:23 +00:00
|
|
|
-{
|
2015-08-19 18:38:23 +00:00
|
|
|
- vnc_sockaddr_t sa;
|
|
|
|
- socklen_t sa_size = sizeof(sa);
|
|
|
|
- return getpeername(sock, &sa.u.sa, &sa_size) >= 0;
|
2013-05-23 11:25:58 +00:00
|
|
|
+ int listening = 0;
|
|
|
|
+ socklen_t listening_size = sizeof(listening);
|
|
|
|
+ return getsockopt(sock, SOL_SOCKET, SO_ACCEPTCONN, &listening,
|
|
|
|
+ &listening_size) >= 0 && listening;
|
|
|
|
}
|
2015-12-01 15:08:23 +00:00
|
|
|
|
2013-05-23 11:25:58 +00:00
|
|
|
int TcpSocket::getSockPort(int sock)
|
2015-08-19 18:38:23 +00:00
|
|
|
diff --git a/common/network/TcpSocket.h b/common/network/TcpSocket.h
|
2015-12-01 15:08:23 +00:00
|
|
|
index 02f04c9..a97e683 100644
|
2015-08-19 18:38:23 +00:00
|
|
|
--- a/common/network/TcpSocket.h
|
|
|
|
+++ b/common/network/TcpSocket.h
|
|
|
|
@@ -65,8 +65,7 @@ namespace network {
|
2015-12-01 15:08:23 +00:00
|
|
|
|
2013-05-23 11:25:58 +00:00
|
|
|
static bool enableNagles(int sock, bool enable);
|
|
|
|
static bool cork(int sock, bool enable);
|
|
|
|
- static bool isSocket(int sock);
|
|
|
|
- static bool isConnected(int sock);
|
|
|
|
+ static bool isListening(int sock);
|
|
|
|
static int getSockPort(int sock);
|
|
|
|
private:
|
|
|
|
bool closeFd;
|
2015-08-19 18:38:23 +00:00
|
|
|
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
|
2015-12-01 15:08:23 +00:00
|
|
|
index 2d918b0..863cd36 100644
|
2015-08-19 18:38:23 +00:00
|
|
|
--- a/unix/xserver/hw/vnc/vncExtInit.cc
|
|
|
|
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
|
|
|
|
@@ -137,8 +137,7 @@ void vncExtensionInit(void)
|
2015-12-01 15:08:23 +00:00
|
|
|
std::list<network::TcpListener*> listeners;
|
|
|
|
std::list<network::TcpListener*> httpListeners;
|
2013-05-23 11:25:58 +00:00
|
|
|
if (scr == 0 && vncInetdSock != -1) {
|
|
|
|
- if (network::TcpSocket::isSocket(vncInetdSock) &&
|
|
|
|
- !network::TcpSocket::isConnected(vncInetdSock))
|
|
|
|
+ if (network::TcpSocket::isListening(vncInetdSock))
|
|
|
|
{
|
2015-12-01 15:08:23 +00:00
|
|
|
listeners.push_back(new network::TcpListener(vncInetdSock));
|
2013-05-23 11:25:58 +00:00
|
|
|
vlog.info("inetd wait");
|