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
a85a11c1
Commit
a85a11c1
authored
Jan 09, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update priority for the stream to get response only
parent
5aa487c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
12 deletions
+77
-12
lib/nghttp2_session.c
lib/nghttp2_session.c
+24
-4
lib/nghttp2_submit.c
lib/nghttp2_submit.c
+0
-4
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+53
-4
No files found.
lib/nghttp2_session.c
View file @
a85a11c1
...
...
@@ -1501,9 +1501,24 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
}
break
;
}
case
NGHTTP2_PRIORITY
:
/* nothing to do */
case
NGHTTP2_PRIORITY
:
{
nghttp2_stream
*
stream
;
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
if
(
!
stream
)
{
break
;
}
/* Only update priority of the stream, only if it is not pushed
stream and is initiated by local peer, or it is pushed stream
and is initiated by remote peer */
if
(((
stream
->
flags
&
NGHTTP2_STREAM_FLAG_PUSH
)
==
0
&&
nghttp2_session_is_my_stream_id
(
session
,
frame
->
hd
.
stream_id
))
||
((
stream
->
flags
&
NGHTTP2_STREAM_FLAG_PUSH
)
&&
!
nghttp2_session_is_my_stream_id
(
session
,
frame
->
hd
.
stream_id
)))
{
nghttp2_session_reprioritize_stream
(
session
,
stream
,
frame
->
priority
.
pri
);
}
break
;
}
case
NGHTTP2_RST_STREAM
:
r
=
nghttp2_session_close_stream
(
session
,
frame
->
hd
.
stream_id
,
frame
->
rst_stream
.
error_code
);
...
...
@@ -2157,8 +2172,13 @@ int nghttp2_session_on_priority_received(nghttp2_session *session,
return
nghttp2_session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_PROTOCOL_ERROR
);
}
/* Only update priority on server side for now */
if
(
session
->
server
)
{
/* Only update priority of the stream, only if it is not pushed
stream and is initiated by remote peer, or it is pushed stream
and is initiated by local peer */
if
(((
stream
->
flags
&
NGHTTP2_STREAM_FLAG_PUSH
)
==
0
&&
!
nghttp2_session_is_my_stream_id
(
session
,
frame
->
hd
.
stream_id
))
||
((
stream
->
flags
&
NGHTTP2_STREAM_FLAG_PUSH
)
&&
nghttp2_session_is_my_stream_id
(
session
,
frame
->
hd
.
stream_id
)))
{
nghttp2_session_reprioritize_stream
(
session
,
stream
,
frame
->
priority
.
pri
);
}
...
...
lib/nghttp2_submit.c
View file @
a85a11c1
...
...
@@ -162,10 +162,6 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
free
(
frame
);
return
r
;
}
/* Only update priority if the sender is client for now */
if
(
!
session
->
server
)
{
nghttp2_session_reprioritize_stream
(
session
,
stream
,
pri
);
}
return
0
;
}
...
...
tests/nghttp2_session_test.c
View file @
a85a11c1
...
...
@@ -1009,19 +1009,42 @@ void test_nghttp2_session_on_priority_received(void)
nghttp2_session_callbacks
callbacks
;
my_user_data
user_data
;
nghttp2_frame
frame
;
nghttp2_stream
*
stream
;
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
on_frame_recv_callback
=
on_frame_recv_callback
;
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
NGHTTP2_PRI_DEFAULT
,
NGHTTP2_STREAM_OPENING
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
NGHTTP2_PRI_DEFAULT
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_frame_priority_init
(
&
frame
.
priority
,
1
,
1000000007
);
/* non-push and initiated by remote peer */
CU_ASSERT
(
0
==
nghttp2_session_on_priority_received
(
session
,
&
frame
));
CU_ASSERT
(
1000000007
==
stream
->
pri
);
/* push and initiated by remote peer: no update */
stream
->
flags
=
NGHTTP2_STREAM_FLAG_PUSH
;
stream
->
pri
=
NGHTTP2_PRI_DEFAULT
;
CU_ASSERT
(
0
==
nghttp2_session_on_priority_received
(
session
,
&
frame
));
CU_ASSERT
(
NGHTTP2_PRI_DEFAULT
==
stream
->
pri
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
NGHTTP2_PRI_DEFAULT
,
NGHTTP2_STREAM_OPENING
,
NULL
);
frame
.
hd
.
stream_id
=
2
;
/* non-push and initiated by local peer: no update */
CU_ASSERT
(
0
==
nghttp2_session_on_priority_received
(
session
,
&
frame
));
CU_ASSERT
(
NGHTTP2_PRI_DEFAULT
==
stream
->
pri
);
/* push and initiated by local peer */
stream
->
flags
=
NGHTTP2_STREAM_FLAG_PUSH
;
CU_ASSERT
(
0
==
nghttp2_session_on_priority_received
(
session
,
&
frame
));
CU_ASSERT
(
1000000007
==
nghttp2_session_get_stream
(
session
,
1
)
->
pri
);
CU_ASSERT
(
1000000007
==
stream
->
pri
);
nghttp2_frame_priority_free
(
&
frame
.
priority
);
nghttp2_session_del
(
session
);
...
...
@@ -2231,11 +2254,37 @@ void test_nghttp2_submit_priority(void)
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_priority
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
-
1
));
/* non-push stream and initiated by local peer */
CU_ASSERT
(
0
==
nghttp2_submit_priority
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
1000000007
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
1000000007
==
stream
->
pri
);
/* push stream and initiated by local peer: no update */
stream
->
flags
=
NGHTTP2_STREAM_FLAG_PUSH
;
stream
->
pri
=
NGHTTP2_PRI_DEFAULT
;
CU_ASSERT
(
0
==
nghttp2_submit_priority
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
1000000007
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
NGHTTP2_PRI_DEFAULT
==
stream
->
pri
);
/* non-push stream and initiated by remote peer: no update */
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
NGHTTP2_PRI_DEFAULT
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_priority
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
1000000007
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
NGHTTP2_PRI_DEFAULT
==
stream
->
pri
);
/* push stream and initiated by remote peer */
stream
->
flags
=
NGHTTP2_STREAM_FLAG_PUSH
;
CU_ASSERT
(
0
==
nghttp2_submit_priority
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
1000000007
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
1000000007
==
stream
->
pri
);
nghttp2_session_del
(
session
);
/* Check that transmission of PRIORITY in reserved(local) is
...
...
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