You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by an...@apache.org on 2010/09/17 00:41:56 UTC

svn commit: r997943 - /trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc

Author: andrewhsu
Date: Thu Sep 16 22:41:56 2010
New Revision: 997943

URL: http://svn.apache.org/viewvc?rev=997943&view=rev
Log:
TS-396 fix crash on macosx

Tested: OSX-10.6.4,RHEL-5.4

Seems as though linux is more forgiving about socket address length
passed to bind(). This change has been tested on Mac OSX and RHEL
using IPv4 and IPv6 requests and all responses were successful.
I'll need somebody else to run tests on the other operating systems
we support (Solaris, etc).

Modified:
    trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc

Modified: trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc?rev=997943&r1=997942&r2=997943&view=diff
==============================================================================
--- trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc (original)
+++ trafficserver/traffic/branches/ipv6/iocore/net/Connection.cc Thu Sep 16 22:41:56 2010
@@ -232,6 +232,7 @@ Server::listen(int port_number, int doma
   struct addrinfo hints;
   struct addrinfo *ai_res = NULL;
   struct addrinfo *ai;
+  socklen_t addrlen = 0;  // keep track of length of socket address info
   snprintf(port, sizeof(port), "%d", port_number);
 
   memset(&hints, 0, sizeof(hints));
@@ -248,6 +249,7 @@ Server::listen(int port_number, int doma
   res = socketManager.socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
 
   memset(&sa, 0, sizeof(sa));
+  addrlen = ai->ai_addrlen;  // save value for later since ai will be freed asap
   memcpy(&sa, ai->ai_addr, ai->ai_addrlen);
 
   freeaddrinfo(ai_res);
@@ -319,7 +321,7 @@ Server::listen(int port_number, int doma
   if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, ON, sizeof(int))) < 0)
     goto Lerror;
 
-  if ((res = socketManager.ink_bind(fd, (struct sockaddr *) &sa, sizeof(sa), IPPROTO_TCP)) < 0) {
+  if ((res = socketManager.ink_bind(fd, (struct sockaddr *) &sa, addrlen, IPPROTO_TCP)) < 0) {
     goto Lerror;
   }
 #ifdef SET_TCP_NO_DELAY