Blob Blame History Raw
diff -up tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.cxx.inetd-nowait tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.cxx
--- tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.cxx.inetd-nowait	2013-05-23 12:20:35.836386218 +0100
+++ tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.cxx	2013-05-23 12:23:04.698003213 +0100
@@ -325,18 +325,12 @@ bool TcpSocket::cork(int sock, bool enab
 #endif
 }
 
-bool TcpSocket::isSocket(int sock)
+bool TcpSocket::isListening(int sock)
 {
-  struct sockaddr_in info;
-  socklen_t info_size = sizeof(info);
-  return getsockname(sock, (struct sockaddr *)&info, &info_size) >= 0;
-}
-
-bool TcpSocket::isConnected(int sock)
-{
-  struct sockaddr_in info;
-  socklen_t info_size = sizeof(info);
-  return getpeername(sock, (struct sockaddr *)&info, &info_size) >= 0;
+  int listening = 0;
+  socklen_t listening_size = sizeof(listening);
+  return getsockopt(sock, SOL_SOCKET, SO_ACCEPTCONN, &listening,
+                    &listening_size) >= 0 && listening;
 }
 
 int TcpSocket::getSockPort(int sock)
diff -up tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.h.inetd-nowait tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.h
--- tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.h.inetd-nowait	2013-05-23 12:20:35.835386220 +0100
+++ tigervnc-1.2.80-20130314svn5065/common/network/TcpSocket.h	2013-05-23 12:21:58.861730647 +0100
@@ -57,8 +57,7 @@ namespace network {
 
     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;
diff -up tigervnc-1.2.80-20130314svn5065/unix/xserver/hw/vnc/vncExtInit.cc.inetd-nowait tigervnc-1.2.80-20130314svn5065/unix/xserver/hw/vnc/vncExtInit.cc
--- tigervnc-1.2.80-20130314svn5065/unix/xserver/hw/vnc/vncExtInit.cc.inetd-nowait	2013-03-14 17:11:22.000000000 +0000
+++ tigervnc-1.2.80-20130314svn5065/unix/xserver/hw/vnc/vncExtInit.cc	2013-05-23 12:21:10.545530308 +0100
@@ -225,8 +225,7 @@ void vncExtensionInit()
         network::TcpListener* listener = 0;
         network::TcpListener* httpListener = 0;
         if (scr == 0 && vncInetdSock != -1) {
-          if (network::TcpSocket::isSocket(vncInetdSock) &&
-              !network::TcpSocket::isConnected(vncInetdSock))
+          if (network::TcpSocket::isListening(vncInetdSock))
           {
             listener = new network::TcpListener(NULL, 0, 0, vncInetdSock, true);
             vlog.info("inetd wait");