Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
eb0a894e
Commit
eb0a894e
authored
Jun 04, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Wshadow' of
https://github.com/alagoutte/nghttp2
into alagoutte-Wshadow
parents
13903783
6b08534f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
41 deletions
+41
-41
lib/nghttp2_hd.c
lib/nghttp2_hd.c
+41
-41
No files found.
lib/nghttp2_hd.c
View file @
eb0a894e
...
...
@@ -228,10 +228,10 @@ static int hd_ringbuf_init(nghttp2_hd_ringbuf *ringbuf, size_t bufsize)
}
static
nghttp2_hd_entry
*
hd_ringbuf_get
(
nghttp2_hd_ringbuf
*
ringbuf
,
size_t
i
nde
x
)
size_t
i
d
x
)
{
assert
(
i
nde
x
<
ringbuf
->
len
);
return
ringbuf
->
buffer
[(
ringbuf
->
first
+
i
nde
x
)
&
ringbuf
->
mask
];
assert
(
i
d
x
<
ringbuf
->
len
);
return
ringbuf
->
buffer
[(
ringbuf
->
first
+
i
d
x
)
&
ringbuf
->
mask
];
}
static
int
hd_ringbuf_reserve
(
nghttp2_hd_ringbuf
*
ringbuf
,
size_t
bufsize
)
...
...
@@ -592,17 +592,17 @@ static int emit_table_size(nghttp2_bufs *bufs, size_t table_size)
return
0
;
}
static
int
emit_indexed_block
(
nghttp2_bufs
*
bufs
,
size_t
i
nde
x
)
static
int
emit_indexed_block
(
nghttp2_bufs
*
bufs
,
size_t
i
d
x
)
{
int
rv
;
size_t
blocklen
;
uint8_t
sb
[
16
];
uint8_t
*
bufp
;
blocklen
=
count_encoded_length
(
i
nde
x
+
1
,
7
);
blocklen
=
count_encoded_length
(
i
d
x
+
1
,
7
);
DEBUGF
(
fprintf
(
stderr
,
"deflatehd: emit indexed index=%zu, %zu bytes
\n
"
,
i
nde
x
,
blocklen
));
i
d
x
,
blocklen
));
if
(
sizeof
(
sb
)
<
blocklen
)
{
return
NGHTTP2_ERR_HEADER_COMP
;
...
...
@@ -610,7 +610,7 @@ static int emit_indexed_block(nghttp2_bufs *bufs, size_t index)
bufp
=
sb
;
*
bufp
=
0x80u
;
encode_length
(
bufp
,
i
nde
x
+
1
,
7
);
encode_length
(
bufp
,
i
d
x
+
1
,
7
);
rv
=
nghttp2_bufs_add
(
bufs
,
sb
,
blocklen
);
if
(
rv
!=
0
)
{
...
...
@@ -673,7 +673,7 @@ static uint8_t pack_first_byte(int inc_indexing, int no_index)
return
0
;
}
static
int
emit_indname_block
(
nghttp2_bufs
*
bufs
,
size_t
i
nde
x
,
static
int
emit_indname_block
(
nghttp2_bufs
*
bufs
,
size_t
i
d
x
,
nghttp2_nv
*
nv
,
int
inc_indexing
)
{
...
...
@@ -697,10 +697,10 @@ static int emit_indname_block(nghttp2_bufs *bufs, size_t index,
DEBUGF
(
fprintf
(
stderr
,
"deflatehd: emit indname index=%zu, valuelen=%zu, "
"indexing=%d, no_index=%d
\n
"
,
i
nde
x
,
nv
->
valuelen
,
inc_indexing
,
no_index
));
i
d
x
,
nv
->
valuelen
,
inc_indexing
,
no_index
));
encvallen
=
nghttp2_hd_huff_encode_count
(
nv
->
value
,
nv
->
valuelen
);
blocklen
=
count_encoded_length
(
i
nde
x
+
1
,
prefixlen
);
blocklen
=
count_encoded_length
(
i
d
x
+
1
,
prefixlen
);
huffman
=
encvallen
<
nv
->
valuelen
;
if
(
!
huffman
)
{
...
...
@@ -715,7 +715,7 @@ static int emit_indname_block(nghttp2_bufs *bufs, size_t index,
*
bufp
=
pack_first_byte
(
inc_indexing
,
no_index
);
encode_length
(
bufp
,
i
nde
x
+
1
,
prefixlen
);
encode_length
(
bufp
,
i
d
x
+
1
,
prefixlen
);
rv
=
nghttp2_bufs_add
(
bufs
,
sb
,
blocklen
);
if
(
rv
!=
0
)
{
...
...
@@ -781,12 +781,12 @@ static int emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv,
* Emit common header with |index| by toggle off and on (thus 2
* indexed representation emissions).
*/
static
int
emit_implicit
(
nghttp2_bufs
*
bufs
,
size_t
i
nde
x
)
static
int
emit_implicit
(
nghttp2_bufs
*
bufs
,
size_t
i
d
x
)
{
int
i
,
rv
;
for
(
i
=
0
;
i
<
2
;
++
i
)
{
rv
=
emit_indexed_block
(
bufs
,
i
nde
x
);
rv
=
emit_indexed_block
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
rv
;
}
...
...
@@ -808,8 +808,8 @@ static nghttp2_hd_entry* add_hd_table_incremental(nghttp2_hd_context *context,
while
(
context
->
hd_table_bufsize
+
room
>
context
->
hd_table_bufsize_max
&&
context
->
hd_table
.
len
>
0
)
{
size_t
i
nde
x
=
context
->
hd_table
.
len
-
1
;
nghttp2_hd_entry
*
ent
=
hd_ringbuf_get
(
&
context
->
hd_table
,
i
nde
x
);
size_t
i
d
x
=
context
->
hd_table
.
len
-
1
;
nghttp2_hd_entry
*
ent
=
hd_ringbuf_get
(
&
context
->
hd_table
,
i
d
x
);
context
->
hd_table_bufsize
-=
entry_room
(
ent
->
nv
.
namelen
,
ent
->
nv
.
valuelen
);
if
(
context
->
role
==
NGHTTP2_HD_ROLE_DEFLATE
)
{
...
...
@@ -817,7 +817,7 @@ static nghttp2_hd_entry* add_hd_table_incremental(nghttp2_hd_context *context,
/* Emit common header just before it slips away from the
table. If we don't do this, we have to emit it in literal
representation which hurts compression. */
rv
=
emit_implicit
(
bufs
,
i
nde
x
);
rv
=
emit_implicit
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
NULL
;
}
...
...
@@ -936,8 +936,8 @@ static void hd_context_shrink_table_size(nghttp2_hd_context *context)
{
while
(
context
->
hd_table_bufsize
>
context
->
hd_table_bufsize_max
&&
context
->
hd_table
.
len
>
0
)
{
size_t
i
nde
x
=
context
->
hd_table
.
len
-
1
;
nghttp2_hd_entry
*
ent
=
hd_ringbuf_get
(
&
context
->
hd_table
,
i
nde
x
);
size_t
i
d
x
=
context
->
hd_table
.
len
-
1
;
nghttp2_hd_entry
*
ent
=
hd_ringbuf_get
(
&
context
->
hd_table
,
i
d
x
);
context
->
hd_table_bufsize
-=
entry_room
(
ent
->
nv
.
namelen
,
ent
->
nv
.
valuelen
);
hd_ringbuf_pop_back
(
&
context
->
hd_table
);
if
(
--
ent
->
ref
==
0
)
{
...
...
@@ -993,9 +993,9 @@ static void clear_refset(nghttp2_hd_context *context)
}
}
static
int
check_index_range
(
nghttp2_hd_context
*
context
,
size_t
i
nde
x
)
static
int
check_index_range
(
nghttp2_hd_context
*
context
,
size_t
i
d
x
)
{
return
i
nde
x
<
context
->
hd_table
.
len
+
STATIC_TABLE_LENGTH
;
return
i
d
x
<
context
->
hd_table
.
len
+
STATIC_TABLE_LENGTH
;
}
static
int
get_max_index
(
nghttp2_hd_context
*
context
)
...
...
@@ -1004,14 +1004,14 @@ static int get_max_index(nghttp2_hd_context *context)
}
nghttp2_hd_entry
*
nghttp2_hd_table_get
(
nghttp2_hd_context
*
context
,
size_t
i
nde
x
)
size_t
i
d
x
)
{
assert
(
check_index_range
(
context
,
i
nde
x
));
if
(
i
nde
x
<
context
->
hd_table
.
len
)
{
return
hd_ringbuf_get
(
&
context
->
hd_table
,
i
nde
x
);
assert
(
check_index_range
(
context
,
i
d
x
));
if
(
i
d
x
<
context
->
hd_table
.
len
)
{
return
hd_ringbuf_get
(
&
context
->
hd_table
,
i
d
x
);
}
else
{
return
&
static_table
[
static_table_index
[
i
nde
x
-
context
->
hd_table
.
len
]].
ent
;
&
static_table
[
static_table_index
[
i
d
x
-
context
->
hd_table
.
len
]].
ent
;
}
}
...
...
@@ -1054,13 +1054,13 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
res
=
search_hd_table
(
&
deflater
->
ctx
,
nv
);
if
(
res
.
index
!=
-
1
&&
res
.
name_value_match
)
{
size_t
i
nde
x
=
res
.
index
;
size_t
i
d
x
=
res
.
index
;
DEBUGF
(
fprintf
(
stderr
,
"deflatehd: name/value match index=%zd
\n
"
,
res
.
index
));
ent
=
nghttp2_hd_table_get
(
&
deflater
->
ctx
,
i
nde
x
);
if
(
i
nde
x
>=
deflater
->
ctx
.
hd_table
.
len
)
{
ent
=
nghttp2_hd_table_get
(
&
deflater
->
ctx
,
i
d
x
);
if
(
i
d
x
>=
deflater
->
ctx
.
hd_table
.
len
)
{
nghttp2_hd_entry
*
new_ent
;
/* It is important to first add entry to the header table and
...
...
@@ -1080,13 +1080,13 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
set */
new_ent
->
flags
|=
NGHTTP2_HD_FLAG_EMIT
;
}
rv
=
emit_indexed_block
(
bufs
,
i
nde
x
);
rv
=
emit_indexed_block
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
rv
;
}
}
else
if
((
ent
->
flags
&
NGHTTP2_HD_FLAG_REFSET
)
==
0
)
{
ent
->
flags
|=
NGHTTP2_HD_FLAG_REFSET
|
NGHTTP2_HD_FLAG_EMIT
;
rv
=
emit_indexed_block
(
bufs
,
i
nde
x
);
rv
=
emit_indexed_block
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
rv
;
}
...
...
@@ -1116,27 +1116,27 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
ent
->
flags
|=
NGHTTP2_HD_FLAG_IMPLICIT_EMIT
;
}
for
(;
num_emits
>
0
;
--
num_emits
)
{
rv
=
emit_indexed_block
(
bufs
,
i
nde
x
);
rv
=
emit_indexed_block
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
rv
;
}
}
}
}
else
{
ssize_t
i
nde
x
=
-
1
;
ssize_t
i
d
x
=
-
1
;
int
incidx
=
0
;
if
(
res
.
index
!=
-
1
)
{
DEBUGF
(
fprintf
(
stderr
,
"deflatehd: name match index=%zd
\n
"
,
res
.
index
));
i
nde
x
=
res
.
index
;
i
d
x
=
res
.
index
;
}
if
(
hd_deflate_should_indexing
(
deflater
,
nv
))
{
nghttp2_hd_entry
*
new_ent
;
if
(
i
nde
x
>=
(
ssize_t
)
deflater
->
ctx
.
hd_table
.
len
)
{
if
(
i
d
x
>=
(
ssize_t
)
deflater
->
ctx
.
hd_table
.
len
)
{
nghttp2_nv
nv_indname
;
nv_indname
=
*
nv
;
nv_indname
.
name
=
nghttp2_hd_table_get
(
&
deflater
->
ctx
,
i
nde
x
)
->
nv
.
name
;
nv_indname
.
name
=
nghttp2_hd_table_get
(
&
deflater
->
ctx
,
i
d
x
)
->
nv
.
name
;
new_ent
=
add_hd_table_incremental
(
&
deflater
->
ctx
,
bufs
,
&
nv_indname
,
NGHTTP2_HD_FLAG_VALUE_ALLOC
);
}
else
{
...
...
@@ -1157,10 +1157,10 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
}
incidx
=
1
;
}
if
(
i
nde
x
==
-
1
)
{
if
(
i
d
x
==
-
1
)
{
rv
=
emit_newname_block
(
bufs
,
nv
,
incidx
);
}
else
{
rv
=
emit_indname_block
(
bufs
,
i
nde
x
,
nv
,
incidx
);
rv
=
emit_indname_block
(
bufs
,
i
d
x
,
nv
,
incidx
);
}
if
(
rv
!=
0
)
{
return
rv
;
...
...
@@ -1170,7 +1170,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
}
static
int
deflate_post_process_hd_entry
(
nghttp2_hd_entry
*
ent
,
size_t
i
nde
x
,
size_t
i
d
x
,
nghttp2_bufs
*
bufs
)
{
int
rv
;
...
...
@@ -1182,7 +1182,7 @@ static int deflate_post_process_hd_entry(nghttp2_hd_entry *ent,
be removed. */
ent
->
flags
^=
NGHTTP2_HD_FLAG_REFSET
;
rv
=
emit_indexed_block
(
bufs
,
i
nde
x
);
rv
=
emit_indexed_block
(
bufs
,
i
d
x
);
if
(
rv
!=
0
)
{
return
rv
;
}
...
...
@@ -2030,11 +2030,11 @@ void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater)
free
(
inflater
);
}
int
nghttp2_hd_emit_indname_block
(
nghttp2_bufs
*
bufs
,
size_t
i
nde
x
,
int
nghttp2_hd_emit_indname_block
(
nghttp2_bufs
*
bufs
,
size_t
i
d
x
,
nghttp2_nv
*
nv
,
int
inc_indexing
)
{
return
emit_indname_block
(
bufs
,
i
nde
x
,
nv
,
inc_indexing
);
return
emit_indname_block
(
bufs
,
i
d
x
,
nv
,
inc_indexing
);
}
int
nghttp2_hd_emit_newname_block
(
nghttp2_bufs
*
bufs
,
nghttp2_nv
*
nv
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment