trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bryancall <...@git.apache.org>
Subject [GitHub] trafficserver pull request: TS-4018: Use HPACK huffman encoding al...
Date Sun, 06 Dec 2015 21:43:53 GMT
Github user bryancall commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/362#discussion_r46776556
  
    --- Diff: proxy/http2/HPACK.cc ---
    @@ -332,18 +332,41 @@ int64_t
     encode_string(uint8_t *buf_start, const uint8_t *buf_end, const char *value, size_t value_len)
     {
       uint8_t *p = buf_start;
    +  bool use_huffman = true;
    +  char *data = NULL;
    +  int64_t data_len = 0;
    +
    +  // TODO Choose whether to use Huffman encoding wisely
    +
    +  if (use_huffman) {
    +    data = static_cast<char *>(ats_malloc(value_len * 4));
    +    if (data == NULL)
    +      return -1;
    +    data_len = huffman_encode(reinterpret_cast<uint8_t *>(data), reinterpret_cast<const
uint8_t *>(value), value_len);
    +  } else {
    +    data = const_cast<char *>(value);
    +    data_len = value_len;
    +  }
     
       // Length
    -  const int64_t len = encode_integer(p, buf_end, value_len, 7);
    +  const int64_t len = encode_integer(p, buf_end, data_len, 7);
       if (len == -1)
         return -1;
    +  if (use_huffman) {
    +    *p |= 0x80;
    +  }
       p += len;
    -  if (buf_end < p || static_cast<size_t>(buf_end - p) < value_len)
    +  if (buf_end < p || static_cast<size_t>(buf_end - p) < data_len)
    --- End diff --
    
    I get this error when compiling:
    HPACK.cc:359:55: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (buf_end < p || static_cast<size_t>(buf_end - p) < data_len)



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message