You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/11/08 16:48:35 UTC
[GitHub] [trafficserver] duke8253 commented on a change in pull request #8498: Use shared pointer to help with high memory utilization
duke8253 commented on a change in pull request #8498:
URL: https://github.com/apache/trafficserver/pull/8498#discussion_r744909960
##########
File path: iocore/net/SSLSessionCache.cc
##########
@@ -338,32 +341,47 @@ SSLOriginSessionCache::insert_session(const std::string &lookup_key, SSL_SESSION
return;
}
- Ptr<IOBufferData> buf;
- buf = new_IOBufferData(buffer_size_to_index(len, MAX_BUFFER_SIZE_INDEX), MEMALIGNED);
- ink_release_assert(static_cast<size_t>(buf->block_size()) >= len);
- unsigned char *loc = reinterpret_cast<unsigned char *>(buf->data());
- i2d_SSL_SESSION(sess, &loc);
+ // Duplicate the session from the connection, we'll be keeping track the ref-count with a shared pointer ourself
+ SSL_SESSION *sess_ptr = SSL_SESSION_dup(sess);
+
+ if (is_debug_tag_set("ssl.origin_session_cache")) {
+ Debug("ssl.origin_session_cache", "insert session: %s = %p", lookup_key.c_str(), sess_ptr);
+ }
+
+ // Create the shared pointer to the session, with the custom deleter
+ std::shared_ptr<SSL_SESSION> shared_sess(sess_ptr, SSLSessDeleter);
ssl_curve_id curve = (ssl == nullptr) ? 0 : SSLGetCurveNID(ssl);
- ats_scoped_obj<SSLOriginSession> ssl_orig_session(new SSLOriginSession(lookup_key, buf, len, curve));
+ ats_scoped_obj<SSLOriginSession> ssl_orig_session(new SSLOriginSession(lookup_key, curve, shared_sess));
auto new_node = ssl_orig_session.release();
+ // Free the shared pointer we're holding right now to make sure the only
+ // reference is inside the "SSLOriginSession" object we just created
+ shared_sess.reset();
Review comment:
Left over code from some testing I was doing, just making sure everything is released where it's supposed so I can make sure the ref-count is correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org