gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, ipv6, updated. release_0_8_9_final-14


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, ipv6, updated. release_0_8_9_final-1450-g5878bc9
Date: Thu, 15 Mar 2012 19:01:58 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, ipv6 has been updated
       via  5878bc9de3bde31df93bed94d25ff5c11a00edc8 (commit)
      from  acc9eb7a10169387a403d523ecf530e55479107a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=5878bc9de3bde31df93bed94d25ff5c11a00edc8


commit 5878bc9de3bde31df93bed94d25ff5c11a00edc8
Author: Rob Savoye <address@hidden>
Date:   Thu Mar 15 13:01:16 2012 -0600

    handle sockaddr correctly for connect()

diff --git a/libbase/Socket.cpp b/libbase/Socket.cpp
index 3b64989..ca921e3 100644
--- a/libbase/Socket.cpp
+++ b/libbase/Socket.cpp
@@ -145,13 +145,10 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
         return false;
     }
 
-    struct sockaddr saddr;
+    // This is used for ::connect()
+    struct sockaddr *saddr = 0;
     
 #ifdef HAVE_IPV6
-    struct sockaddr_in6 addr6;
-    // std::memset(&addr6, 0, sizeof(addr6));
-    // addr.sin6_family = AF_INET6;
-    // addr.sin6_port = htons(port);
     int code = 0;
     struct addrinfo req, *ans;
     std::memset(&req, 0, sizeof(struct addrinfo));
@@ -183,14 +180,12 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
                     sizeof(straddr));
         log_debug("IPV6 address for host %s is %s", hostname, straddr);
 
-        addr6.sin6_family = AF_INET6;
-        addr6.sin6_port = htons(port);
         _socket = ::socket(it->ai_family, it->ai_socktype, it->ai_protocol);
-        
         if (_socket < 0) {
             const int err = errno;
             log_error(_("Socket creation failed: %s"), std::strerror(err));
             _socket = 0;
+            // Try the next IP number
             it = it->ai_next;
         } else {
             break;
@@ -198,8 +193,12 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
     }
 
     // cache the data we need later
-    std::memcpy(&saddr, ans->ai_addr, ans->ai_addrlen);
-    const int addrlen = ans->ai_addrlen;    
+    struct sockaddr_in6 *addr6 = reinterpret_cast<struct sockaddr_in6 
*>(it->ai_addr);
+    // When NULL is passed to getaddrinfo(), the port isn't set in
+    // the returned data, so we do it here.
+    addr6->sin6_port = htons(port);
+    saddr = it->ai_addr;
+    const int addrlen = it->ai_addrlen;
 
     freeaddrinfo(ans);          // free the response data
 #else
@@ -223,8 +222,9 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
             return false;
         }
     }
-    std::memcpy(&saddr, &addr, sizeof(struct sockaddr));
+    // cache the data we need later
     const int addrlen = sizeof(struct sockaddr);
+    saddr = reinterpret_cast<struct sockaddr *>(&addr);
 #endif
 
 #ifndef _WIN32
@@ -234,11 +234,11 @@ Socket::connect(const std::string& hostname, 
boost::uint16_t port)
 #endif
 
     // Attempt connection
-    if (::connect(_socket, &saddr, addrlen) < 0) {
+    if (::connect(_socket, saddr, addrlen) < 0) {
         const int err = errno;
 #ifndef _WIN32
         if (err != EINPROGRESS) {
-            log_error(_("Failed to connect socket: %s"), std::strerror(err));
+            log_error(_("Failed to connect to socket: %s"), 
std::strerror(err));
             _socket = 0;
             return false;
         }

-----------------------------------------------------------------------

Summary of changes:
 libbase/Socket.cpp |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]