rpms/vnc/devel vnc-viewerIPv6.patch,1.1,1.2 vnc.spec,1.192,1.193

Adam Tkac (atkac) fedora-extras-commits at redhat.com
Tue Jun 3 08:58:00 UTC 2008


Author: atkac

Update of /cvs/pkgs/rpms/vnc/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20223

Modified Files:
	vnc-viewerIPv6.patch vnc.spec 
Log Message:
- minor cleanup in IPv6 patch


vnc-viewerIPv6.patch:

Index: vnc-viewerIPv6.patch
===================================================================
RCS file: /cvs/pkgs/rpms/vnc/devel/vnc-viewerIPv6.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vnc-viewerIPv6.patch	29 May 2008 16:37:19 -0000	1.1
+++ vnc-viewerIPv6.patch	3 Jun 2008 08:57:07 -0000	1.2
@@ -1,28 +1,28 @@
 diff -up vnc-4_1_2-unixsrc/common/network/Makefile.am.ipv6 vnc-4_1_2-unixsrc/common/network/Makefile.am
---- vnc-4_1_2-unixsrc/common/network/Makefile.am.ipv6	2008-05-29 17:53:53.000000000 +0200
-+++ vnc-4_1_2-unixsrc/common/network/Makefile.am	2008-05-29 17:53:53.000000000 +0200
+--- vnc-4_1_2-unixsrc/common/network/Makefile.am.ipv6	2008-06-02 10:22:17.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/network/Makefile.am	2008-06-02 10:52:56.000000000 +0200
 @@ -1,5 +1,7 @@
  noinst_LTLIBRARIES = libnetwork.la
  
-+libnetwork_la_CPPFLAGS = -DHAVE_IPV6
++libnetwork_la_CPPFLAGS = -DHAVE_GETADDRINFO
 +
  libnetwork_la_SOURCES = \
  	Socket.h \
  	TcpSocket.cxx \
 diff -up vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.ipv6 vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx
---- vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.ipv6	2008-05-29 17:53:53.000000000 +0200
-+++ vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx	2008-05-29 18:18:28.000000000 +0200
-@@ -109,50 +109,100 @@ TcpSocket::TcpSocket(int sock, bool clos
+--- vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.ipv6	2008-06-02 10:22:17.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx	2008-06-02 10:49:04.000000000 +0200
+@@ -109,50 +109,99 @@ TcpSocket::TcpSocket(int sock, bool clos
  TcpSocket::TcpSocket(const char *host, int port)
    : closeFd(true)
  {
 -  int sock;
-+  int sock, err, family, ret;
++#define CAST_ADDR(x) (*((struct x *)&addr))
++  int sock, err, family, result = -1;
 +  size_t addrlen;
 +  struct sockaddr_storage addr;
-+#ifdef HAVE_IPV6
-+  struct addrinfo *hostai, *current, hints;
-+  char errstr[256];
++#ifdef HAVE_GETADDRINFO
++  struct addrinfo *ai, *current, hints;
 +#endif
  
    // - Create a socket
@@ -34,7 +34,7 @@
 -  // - By default, close the socket on exec()
 -  fcntl(sock, F_SETFD, FD_CLOEXEC);
 -#endif
-+#ifdef HAVE_IPV6
++#ifdef HAVE_GETADDRINFO
 +  memset(&hints, 0, sizeof(struct addrinfo));
 +  hints.ai_family = AF_UNSPEC;
 +  hints.ai_socktype = SOCK_STREAM;
@@ -42,15 +42,12 @@
 +  hints.ai_addr = NULL;
 +  hints.ai_next = NULL;
 +
-+  if (getaddrinfo(host, NULL, &hints, &hostai) != 0) {
-+    err = errorNumber;
-+    if (snprintf(errstr, 256, "unable resolve host by name (%s)",
-+	gai_strerror(err)) < 0)
-+      throw Exception("unable resolve host by name");
-+    throw Exception(errstr);
++  if ((result = getaddrinfo(host, NULL, &hints, &ai)) != 0) {
++    throw Exception("unable to resolve host by name: %s",
++		    gai_strerror(result));
 +  }
 +
-+  for (current = hostai; current != NULL; current = hostai->ai_next) {
++  for (current = ai; current != NULL; current = current->ai_next) {
 +    family = current->ai_family;
 +    if (family != AF_INET && family != AF_INET6)
 +      continue;
@@ -59,9 +56,9 @@
 +    memcpy(&addr, current->ai_addr, addrlen);
 +
 +    if (family == AF_INET)
-+      ((struct sockaddr_in *)&addr)->sin_port = htons(port);
++      CAST_ADDR(sockaddr_in).sin_port = htons(port);
 +    else
-+      ((struct sockaddr_in6 *)&addr)->sin6_port = htons(port);
++      CAST_ADDR(sockaddr_in6).sin6_port = htons(port);
  
 -  // - Connect it to something
 +#else
@@ -86,27 +83,29 @@
 -      throw SocketException("unable to resolve host by name", e);
 +    // Try processing the host as an IP address
 +    memset(&addr, 0, addrlen);
-+    addr.sin_family = AF_INET;
-+    addr.sin_addr.s_addr = inet_addr(host);
-+    addr.sin_port = htons(port);
-+    if ((int)addr.sin_addr.s_addr == -1) {
++    CAST_ADDR(sockaddr_in).sin_family = AF_INET;
++    CAST_ADDR(sockaddr_in).sin_addr.s_addr = inet_addr(host);
++    CAST_ADDR(sockaddr_in).sin_port = htons(port);
++    if ((int)CAST_ADDR(sockaddr_in).sin_addr.s_addr == -1) {
 +      // Host was not an IP address - try resolving as DNS name
 +      struct hostent *hostinfo;
 +      hostinfo = gethostbyname(host);
 +      if (hostinfo && hostinfo->h_addr) {
-+	addr.sin_addr.s_addr = ((struct in_addr *)hostinfo->h_addr)->s_addr;
++	CAST_ADDR(sockaddr_in).sin_addr.s_addr =
++	  ((struct in_addr *)hostinfo->h_addr)->s_addr;
 +      } else {
 +	err = errorNumber;
-+	strcpy(errstr, "unable to resolve host by name");
-+	goto socket_fail;
++	throw SocketException("unable to resolve host by name", err);
 +      }
 +    }
 +#endif
 +    sock = socket (family, SOCK_STREAM, 0);
 +    if (sock == -1) {
-+      err = errno;
-+      strcpy(errstr, "unable to create socket");
-+      goto socket_fail;
++      err = errorNumber;
++#ifdef HAVE_GETADDRINFO
++      freeaddrinfo(ai);
++#endif
++      throw SocketException("unable to create socket", err);
      }
 -  }
  
@@ -117,7 +116,7 @@
 -      if (e == EINTR)
 -        continue;
 +    // Attempt to connect to the remote host
-+    while ((ret = connect(sock, (struct sockaddr *)&addr, addrlen)) == -1) {
++    while ((result = connect(sock, (struct sockaddr *)&addr, addrlen)) == -1) {
 +      err = errorNumber;
 +      if (err == EINTR)
 +	continue;
@@ -126,18 +125,18 @@
 -    } else break;
 +      break;
 +    }
-+#ifdef HAVE_IPV6
-+    if (ret == 0)
++#ifdef HAVE_GETADDRINFO
++    if (result == 0)
 +      break;
 +    else
 +      continue;
-+  }
-+#endif
-+  if (ret == -1) {
-+    strcpy(errstr, "unable to connect to host");
-+    goto socket_fail;
    }
  
++  freeaddrinfo(ai);
++#endif
++  if (result == -1)
++    throw SocketException("unable connect to socket", err);
++
 +#ifndef WIN32
 +  // - By default, close the socket on exec()
 +  fcntl(sock, F_SETFD, FD_CLOEXEC);
@@ -146,18 +145,48 @@
    // Disable Nagle's algorithm, to reduce latency
    enableNagles(sock, false);
  
-@@ -160,6 +210,14 @@ TcpSocket::TcpSocket(const char *host, i
-   instream = new FdInStream(sock);
-   outstream = new FdOutStream(sock);
-   ownStreams = true;
-+
-+  return;
-+
-+socket_fail:
-+#ifdef HAVE_IPV6
-+  freeaddrinfo(hostai);
-+#endif
-+  throw SocketException(errstr, err);
- }
+diff -up vnc-4_1_2-unixsrc/common/rdr/Exception.cxx.ipv6 vnc-4_1_2-unixsrc/common/rdr/Exception.cxx
+--- vnc-4_1_2-unixsrc/common/rdr/Exception.cxx.ipv6	2008-06-02 10:23:35.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/rdr/Exception.cxx	2008-06-02 10:28:51.000000000 +0200
+@@ -22,8 +22,23 @@
+ #include <winsock2.h>
+ #endif
+ 
++#include <stdarg.h>
++
+ using namespace rdr;
+ 
++Exception::Exception(const char *format, ...) {
++  va_list ap;
++  int result;
++
++  va_start(ap, format);
++  result = vsnprintf(str_, len, format, ap);
++  va_end(ap);
++
++  /* XXX - ensure that string ends correctly */
++  if (result > len)
++    str_[len - 1] = '\0';
++}
++
+ SystemException::SystemException(const char* s, int err_)
+   : Exception(s), err(err_)
+ {
+diff -up vnc-4_1_2-unixsrc/common/rdr/Exception.h.ipv6 vnc-4_1_2-unixsrc/common/rdr/Exception.h
+--- vnc-4_1_2-unixsrc/common/rdr/Exception.h.ipv6	2008-06-02 10:23:05.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/rdr/Exception.h	2008-06-02 10:28:41.000000000 +0200
+@@ -27,13 +27,7 @@ namespace rdr {
+   struct Exception {
+     enum { len = 256 };
+     char str_[len];
+-    Exception(const char* s=0) {
+-      str_[0] = 0;
+-      if (s)
+-        strncat(str_, s, len-1);
+-      else
+-        strcat(str_, "Exception");
+-    }
++    Exception(const char *format, ...);
+     virtual const char* str() const { return str_; }
+   };
  
- TcpSocket::~TcpSocket() {


Index: vnc.spec
===================================================================
RCS file: /cvs/pkgs/rpms/vnc/devel/vnc.spec,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -r1.192 -r1.193
--- vnc.spec	29 May 2008 16:37:19 -0000	1.192
+++ vnc.spec	3 Jun 2008 08:57:07 -0000	1.193
@@ -3,7 +3,7 @@
 Summary:   A remote display system
 Name:      vnc
 Version:   4.1.2
-Release:   31%{?dist}
+Release:   31.1%{?dist}
 URL:       http://www.realvnc.com
 Source0:   http://www.realvnc.com/dist/vnc-%{vnc_version}-unixsrc.tar.gz
 Source1:   Makefile.am
@@ -335,6 +335,9 @@
 %{_libdir}/librfb.so.*
 
 %changelog
+* Mon Jun 02 2008 Adam Tkac <atkac redhat com> 4.1.2-31.1
+- minor cleanup in IPv6 patch
+
 * Wed May 29 2008 Adam Tkac <atkac redhat com> 4.1.2-31
 - substituted vnc-210617.patch with improved version - vnc-viewerIPv6.patch
   (#438422)




More information about the fedora-extras-commits mailing list