maskit commented on code in PR #13284:
URL: https://github.com/apache/trafficserver/pull/13284#discussion_r3424243636


##########
src/iocore/net/TLSCertCompression_zlib.cc:
##########
@@ -28,9 +28,25 @@
 #include <zlib.h>
 
 int
-compression_func_zlib(SSL * /* ssl */, CBB *out, const uint8_t *in, size_t 
in_len)
+compression_func_zlib(SSL *ssl, CBB *out, const uint8_t *in, size_t in_len)
 {
-  // TODO Need a cache mechanism inside this function for better performance.
+  auto *cache = cert_compress_cache_get(SSL_get_SSL_CTX(ssl));
+
+  if (cache) {
+    auto const *entry = 
cache->slots[CERT_COMPRESS_ALG_ZLIB].live.load(std::memory_order_acquire);
+    if (entry) {
+      uint8_t *buf;
+      if (CBB_reserve(out, &buf, entry->bytes.size()) != 1) {
+        Metrics::Counter::increment(ssl_rsb.cert_compress_zlib_failure);
+        return 0;
+      }
+      memcpy(buf, entry->bytes.data(), entry->bytes.size());

Review Comment:
   Fixed it.



##########
src/iocore/net/TLSCertCompression_brotli.cc:
##########
@@ -29,9 +29,25 @@
 #include <brotli/encode.h>
 
 int
-compression_func_brotli(SSL * /* ssl */, CBB *out, const uint8_t *in, size_t 
in_len)
+compression_func_brotli(SSL *ssl, CBB *out, const uint8_t *in, size_t in_len)
 {
-  // TODO Need a cache mechanism inside this function for better performance.
+  auto *cache = cert_compress_cache_get(SSL_get_SSL_CTX(ssl));
+
+  if (cache) {
+    auto const *entry = 
cache->slots[CERT_COMPRESS_ALG_BROTLI].live.load(std::memory_order_acquire);
+    if (entry) {
+      uint8_t *buf;
+      if (CBB_reserve(out, &buf, entry->bytes.size()) != 1) {
+        Metrics::Counter::increment(ssl_rsb.cert_compress_brotli_failure);
+        return 0;
+      }
+      memcpy(buf, entry->bytes.data(), entry->bytes.size());

Review Comment:
   Fixed it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to