From: Viswanath Sivakumar Date: Wed, 28 Jan 2015 20:08:36 +0000 (-0800) Subject: Convert TransportInfo SSL fields to shared_ptrs X-Git-Tag: v0.23.0~13 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a803ace46cb1d6e2a388bf987331d0645b77730f;p=folly.git Convert TransportInfo SSL fields to shared_ptrs Summary: We do a lot of copying of TransportInfo in proxygen, and in most cases the SSL structs don't change after connection establishment. We could cut down on memory usage by sharing these huge strings. This is especially true with SPDY where all streams belonging to a session could share these fields. Facebook: Test Plan: Unit tests, will canary Reviewed By: afrind@fb.com Subscribers: fugalh, bmatheny, ssl-diffs@, folly-diffs@, jsedgwick, woo FB internal diff: D1807557 Tasks: 5343753 Signature: t1:1807557:1422472932:53038345fca620632097586fb9e410bca8fe748d --- diff --git a/folly/wangle/acceptor/Acceptor.cpp b/folly/wangle/acceptor/Acceptor.cpp index 2d31e719..8e616c23 100644 --- a/folly/wangle/acceptor/Acceptor.cpp +++ b/folly/wangle/acceptor/Acceptor.cpp @@ -118,13 +118,17 @@ class AcceptorHandshakeHelper : tinfo.sslVersion = sock->getSSLVersion(); tinfo.sslCertSize = sock->getSSLCertSize(); tinfo.sslResume = SSLUtil::getResumeState(sock); - sock->getSSLClientCiphers(tinfo.sslClientCiphers); - sock->getSSLServerCiphers(tinfo.sslServerCiphers); - tinfo.sslClientComprMethods = sock->getSSLClientComprMethods(); - tinfo.sslClientExts = sock->getSSLClientExts(); - tinfo.sslNextProtocol.assign( - reinterpret_cast(nextProto), - nextProtoLength); + tinfo.sslClientCiphers = std::make_shared(); + sock->getSSLClientCiphers(*tinfo.sslClientCiphers); + tinfo.sslServerCiphers = std::make_shared(); + sock->getSSLServerCiphers(*tinfo.sslServerCiphers); + tinfo.sslClientComprMethods = + std::make_shared(sock->getSSLClientComprMethods()); + tinfo.sslClientExts = + std::make_shared(sock->getSSLClientExts()); + tinfo.sslNextProtocol = std::make_shared(); + tinfo.sslNextProtocol->assign(reinterpret_cast(nextProto), + nextProtoLength); acceptor_->updateSSLStats(sock, tinfo.sslSetupTime, SSLErrorEnum::NO_ERROR); acceptor_->downstreamConnectionManager_->removeConnection(this); diff --git a/folly/wangle/acceptor/TransportInfo.h b/folly/wangle/acceptor/TransportInfo.h index 831e2517..c02bac42 100644 --- a/folly/wangle/acceptor/TransportInfo.h +++ b/folly/wangle/acceptor/TransportInfo.h @@ -86,37 +86,37 @@ struct TransportInfo { /* * list of ciphers sent by the client */ - std::string sslClientCiphers{}; + std::shared_ptr sslClientCiphers{nullptr}; /* * list of compression methods sent by the client */ - std::string sslClientComprMethods{}; + std::shared_ptr sslClientComprMethods{nullptr}; /* * list of TLS extensions sent by the client */ - std::string sslClientExts{}; + std::shared_ptr sslClientExts{nullptr}; /* * hash of all the SSL parameters sent by the client */ - std::string sslSignature{}; + std::shared_ptr sslSignature{nullptr}; /* * list of ciphers supported by the server */ - std::string sslServerCiphers{}; + std::shared_ptr sslServerCiphers{nullptr}; /* * guessed "(os) (browser)" based on SSL Signature */ - std::string guessedUserAgent{}; + std::shared_ptr guessedUserAgent{nullptr}; /** * The result of SSL NPN negotiation. */ - std::string sslNextProtocol{}; + std::shared_ptr sslNextProtocol{nullptr}; /* * total number of bytes sent over the connection