Adjust transmission frame buffer size to support maximum payload size

This commit is contained in:
Tatsuhiro Tsujikawa 2014-04-02 20:33:01 +09:00
parent 9d9eb48258
commit 9c4c99bf96
3 changed files with 13 additions and 18 deletions

View File

@ -43,18 +43,16 @@
/* The number of bytes of frame header. */
#define NGHTTP2_FRAME_HDLEN 8
/* The maximum frame and payload length. The spec allows maximum
payload length up to 16383 bytes. Due to efficient buffer
allocation, we choose smaller buffer. Actual payload limit offsets
frame header and possible PAD_HIGH and PAD_LOW to ease
serialization and save memcopying. */
#define NGHTTP2_MAX_FRAMELEN 8192
#define NGHTTP2_MAX_PAYLOADLEN (NGHTTP2_MAX_FRAMELEN - NGHTTP2_FRAME_HDLEN - 2)
#define NGHTTP2_MAX_PAYLOADLEN 16383
/* The one frame buffer length for tranmission. We may use several of
them to support CONTINUATION. To account for padding specifiers
(PAD_HIGH and PAD_LOW), we allocate extra 2 bytes, which saves
extra large memcopying. */
#define NGHTTP2_FRAMEBUF_CHUNKLEN \
(NGHTTP2_FRAME_HDLEN + 2 + NGHTTP2_MAX_PAYLOADLEN)
/* The maximum length of DATA frame payload. To fit entire DATA frame
into 4096K buffer, we use subtract header size (8 bytes) + 2 bytes
padding. See nghttp2_session_pack_data(). */
#define NGHTTP2_DATA_PAYLOAD_LENGTH (4096 - NGHTTP2_FRAME_HDLEN - 2)
/* The maximum length of DATA frame payload. */
#define NGHTTP2_DATA_PAYLOAD_LENGTH 4096
/* The number of bytes for each SETTINGS entry */
#define NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH 5

View File

@ -321,12 +321,9 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
(*session_ptr)->server = 1;
}
/* 2 for PAD_HIGH and PAD_LOW. We have maximum 64KB of frame
serialization buffer for transmission */
/* 2 for PAD_HIGH and PAD_LOW. */
rv = nghttp2_bufs_init3(&(*session_ptr)->aob.framebufs,
NGHTTP2_MAX_FRAMELEN,
(1 << 17) / NGHTTP2_MAX_FRAMELEN,
(1 << 13) / NGHTTP2_MAX_FRAMELEN,
NGHTTP2_FRAMEBUF_CHUNKLEN, 8, 1,
NGHTTP2_FRAME_HDLEN + 2);
if(rv != 0) {
goto fail_aob_framebuf;

View File

@ -4659,7 +4659,7 @@ void test_nghttp2_session_pack_headers_with_padding(void)
accumulator acc;
my_user_data ud;
nghttp2_session_callbacks callbacks;
nghttp2_nv nva[4086];
nghttp2_nv nva[8172];
size_t i;
nghttp2_priority_spec pri_spec;
@ -4725,7 +4725,7 @@ void test_nghttp2_session_pack_headers_with_padding2(void)
accumulator acc;
my_user_data ud;
nghttp2_session_callbacks callbacks;
nghttp2_nv nva[8182];
nghttp2_nv nva[16364];
size_t i;
for(i = 0; i < ARRLEN(nva); ++i) {