trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [1/2] git commit: TS-2802: Additional fixups. Changed NetVCOptions to use ats_scoped_str instead of a raw pointer. Added comments.
Date Fri, 19 Sep 2014 13:30:22 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master a9905459d -> 4a143e584


TS-2802: Additional fixups.
         Changed NetVCOptions to use ats_scoped_str instead of a raw pointer.
         Added comments.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4b48b2c2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4b48b2c2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4b48b2c2

Branch: refs/heads/master
Commit: 4b48b2c208f7e5607c27653bb407784e2cac1926
Parents: a990545
Author: Alan M. Carroll <amc@network-geographics.com>
Authored: Thu Sep 18 15:45:26 2014 -0500
Committer: Alan M. Carroll <amc@network-geographics.com>
Committed: Thu Sep 18 15:45:26 2014 -0500

----------------------------------------------------------------------
 iocore/net/I_NetVConnection.h     | 30 ++++++++++++++++++------------
 iocore/net/P_UnixNetVConnection.h |  1 -
 iocore/net/SSLNetVConnection.cc   |  4 ++--
 3 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b48b2c2/iocore/net/I_NetVConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index dcf86a7..cf97c64 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -159,7 +159,9 @@ struct NetVCOptions {
 
   EventType etype;
 
-  char * sni_servername; // SSL SNI to origin
+  /** Server name to use for SNI data on an outbound connection.
+   */
+  ats_scoped_str sni_servername;
 
   /// Reset all values to defaults.
   void reset();
@@ -167,31 +169,35 @@ struct NetVCOptions {
   void set_sock_param(int _recv_bufsize, int _send_bufsize, unsigned long _opt_flags,
                       unsigned long _packet_mark = 0, unsigned long _packet_tos = 0);
 
-  NetVCOptions() : sni_servername(NULL) {
+  NetVCOptions() {
     reset();
   }
 
   ~NetVCOptions() {
-    ats_free(sni_servername);
   }
 
-  void set_sni_servername(const char * name, size_t len) {
+  /** Set the SNI server name.
+      A local copy is made of @a name.
+  */
+  self& set_sni_servername(const char * name, size_t len) {
     IpEndpoint ip;
 
-    ats_free(sni_servername);
-    sni_servername = NULL;
     // Literal IPv4 and IPv6 addresses are not permitted in "HostName".(rfc6066#section-3)
     if (ats_ip_pton(ts::ConstBuffer(name, len), &ip) != 0) {
       sni_servername = ats_strndup(name, len);
+    } else {
+      sni_servername = NULL;
     }
+    return *this;
   }
 
-  NetVCOptions & operator=(const NetVCOptions & opt) {
-    if (&opt != this) {
-      ats_free(this->sni_servername);
-      memcpy(this, &opt, sizeof(opt));
-      if (opt.sni_servername) {
-        this->sni_servername = ats_strdup(opt.sni_servername);
+  self& operator=(self const& that) {
+    if (&that != this) {
+      sni_servername = NULL; // release any current name.
+      memcpy(this, &that, sizeof(self));
+      if (that.sni_servername) {
+	sni_servername.release(); // otherwise we'll free the source string.
+        this->sni_servername = ats_strdup(that.sni_servername);
       }
     }
     return *this;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b48b2c2/iocore/net/P_UnixNetVConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h
index 0b7845e..7fb597d 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -66,7 +66,6 @@ NetVCOptions::reset()
 
   etype = ET_NET;
 
-  ats_free(sni_servername);
   sni_servername = NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b48b2c2/iocore/net/SSLNetVConnection.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index d3aa858..7978013 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -666,9 +666,9 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err)
 #if TS_USE_TLS_SNI
   if (options.sni_servername) {
     if (SSL_set_tlsext_host_name(ssl, options.sni_servername)) {
-      Debug("ssl", "using SNI name '%s' for client handshake", options.sni_servername);
+      Debug("ssl", "using SNI name '%s' for client handshake", options.sni_servername.get());
     } else {
-      Debug("ssl.error","failed to set SNI name '%s' for client handshake", options.sni_servername);
+      Debug("ssl.error","failed to set SNI name '%s' for client handshake", options.sni_servername.get());
       SSL_INCREMENT_DYN_STAT(ssl_sni_name_set_failure);
     }
   }


Mime
View raw message