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
5597ee68
Commit
5597ee68
authored
Sep 20, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shrpx: Use raw pointer for downstream instead of deque
parent
c78e0ca0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
50 deletions
+29
-50
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+25
-43
src/shrpx_https_upstream.h
src/shrpx_https_upstream.h
+4
-7
No files found.
src/shrpx_https_upstream.cc
View file @
5597ee68
...
...
@@ -48,6 +48,7 @@ HttpsUpstream::HttpsUpstream(ClientHandler *handler)
:
handler_
(
handler
),
htp_
(
new
http_parser
()),
current_header_length_
(
0
),
downstream_
(
0
),
ioctrl_
(
handler
->
get_bev
())
{
http_parser_init
(
htp_
,
HTTP_REQUEST
);
...
...
@@ -57,10 +58,7 @@ HttpsUpstream::HttpsUpstream(ClientHandler *handler)
HttpsUpstream
::~
HttpsUpstream
()
{
delete
htp_
;
for
(
std
::
deque
<
Downstream
*>::
iterator
i
=
downstream_queue_
.
begin
();
i
!=
downstream_queue_
.
end
();
++
i
)
{
delete
*
i
;
}
delete
downstream_
;
}
void
HttpsUpstream
::
reset_current_header_length
()
...
...
@@ -78,7 +76,7 @@ int htp_msg_begin(http_parser *htp)
}
upstream
->
reset_current_header_length
();
Downstream
*
downstream
=
new
Downstream
(
upstream
,
0
,
0
);
upstream
->
a
dd
_downstream
(
downstream
);
upstream
->
a
ttach
_downstream
(
downstream
);
return
0
;
}
}
// namespace
...
...
@@ -88,7 +86,7 @@ int htp_uricb(http_parser *htp, const char *data, size_t len)
{
HttpsUpstream
*
upstream
;
upstream
=
reinterpret_cast
<
HttpsUpstream
*>
(
htp
->
data
);
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
downstream
->
append_request_path
(
data
,
len
);
return
0
;
}
...
...
@@ -99,7 +97,7 @@ int htp_hdr_keycb(http_parser *htp, const char *data, size_t len)
{
HttpsUpstream
*
upstream
;
upstream
=
reinterpret_cast
<
HttpsUpstream
*>
(
htp
->
data
);
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
if
(
downstream
->
get_request_header_key_prev
())
{
downstream
->
append_last_request_header_key
(
data
,
len
);
}
else
{
...
...
@@ -114,7 +112,7 @@ int htp_hdr_valcb(http_parser *htp, const char *data, size_t len)
{
HttpsUpstream
*
upstream
;
upstream
=
reinterpret_cast
<
HttpsUpstream
*>
(
htp
->
data
);
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
if
(
downstream
->
get_request_header_key_prev
())
{
downstream
->
set_last_request_header_value
(
std
::
string
(
data
,
len
));
}
else
{
...
...
@@ -132,7 +130,7 @@ int htp_hdrs_completecb(http_parser *htp)
if
(
ENABLE_LOG
)
{
LOG
(
INFO
)
<<
"Upstream https request headers complete "
<<
upstream
;
}
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
downstream
->
set_request_method
(
http_method_str
((
enum
http_method
)
htp
->
method
));
downstream
->
set_request_major
(
htp
->
http_major
);
...
...
@@ -175,7 +173,7 @@ int htp_bodycb(http_parser *htp, const char *data, size_t len)
int
rv
;
HttpsUpstream
*
upstream
;
upstream
=
reinterpret_cast
<
HttpsUpstream
*>
(
htp
->
data
);
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
rv
=
downstream
->
push_upload_data_chunk
(
reinterpret_cast
<
const
uint8_t
*>
(
data
),
len
);
if
(
rv
!=
0
)
{
...
...
@@ -194,7 +192,7 @@ int htp_msg_completecb(http_parser *htp)
}
HttpsUpstream
*
upstream
;
upstream
=
reinterpret_cast
<
HttpsUpstream
*>
(
htp
->
data
);
Downstream
*
downstream
=
upstream
->
get_
last_
downstream
();
Downstream
*
downstream
=
upstream
->
get_downstream
();
rv
=
downstream
->
end_upload_data
();
if
(
rv
!=
0
)
{
return
-
1
;
...
...
@@ -238,7 +236,7 @@ int HttpsUpstream::on_read()
evbuffer_drain
(
input
,
nread
);
// Well, actually header length + some body bytes
current_header_length_
+=
nread
;
Downstream
*
downstream
=
get_
top_
downstream
();
Downstream
*
downstream
=
get_downstream
();
http_errno
htperr
=
HTTP_PARSER_ERRNO
(
htp_
);
if
(
htperr
==
HPE_PAUSED
)
{
if
(
downstream
->
get_request_state
()
==
Downstream
::
CONNECT_FAIL
)
{
...
...
@@ -252,8 +250,7 @@ int HttpsUpstream::on_read()
if
(
downstream
->
get_downstream_connection
()
==
0
)
{
// Error response already be sent
assert
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
);
pop_downstream
();
delete
downstream
;
delete_downstream
();
}
else
{
pause_read
(
SHRPX_MSG_BLOCK
);
}
...
...
@@ -296,7 +293,7 @@ void https_downstream_readcb(bufferevent *bev, void *ptr);
int
HttpsUpstream
::
on_write
()
{
Downstream
*
downstream
=
get_
top_
downstream
();
Downstream
*
downstream
=
get_downstream
();
if
(
downstream
)
{
downstream
->
resume_read
(
SHRPX_NO_BUFFER
);
}
...
...
@@ -357,8 +354,7 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
delete
handler
;
return
;
}
else
{
upstream
->
pop_downstream
();
delete
downstream
;
upstream
->
delete_downstream
();
// Process next HTTP request
upstream
->
resume_read
(
SHRPX_MSG_BLOCK
);
}
...
...
@@ -384,8 +380,7 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
return
;
}
if
(
downstream
->
get_request_state
()
==
Downstream
::
MSG_COMPLETE
)
{
upstream
->
pop_downstream
();
delete
downstream
;
upstream
->
delete_downstream
();
// Process next HTTP request
upstream
->
resume_read
(
SHRPX_MSG_BLOCK
);
}
...
...
@@ -452,8 +447,7 @@ void https_downstream_eventcb(bufferevent *bev, short events, void *ptr)
}
}
if
(
downstream
->
get_request_state
()
==
Downstream
::
MSG_COMPLETE
)
{
upstream
->
pop_downstream
();
delete
downstream
;
upstream
->
delete_downstream
();
upstream
->
resume_read
(
SHRPX_MSG_BLOCK
);
}
}
else
if
(
events
&
(
BEV_EVENT_ERROR
|
BEV_EVENT_TIMEOUT
))
{
...
...
@@ -473,8 +467,7 @@ void https_downstream_eventcb(bufferevent *bev, short events, void *ptr)
}
}
if
(
downstream
->
get_request_state
()
==
Downstream
::
MSG_COMPLETE
)
{
upstream
->
pop_downstream
();
delete
downstream
;
upstream
->
delete_downstream
();
upstream
->
resume_read
(
SHRPX_MSG_BLOCK
);
}
}
...
...
@@ -500,7 +493,7 @@ int HttpsUpstream::error_reply(int status_code)
LOG
(
FATAL
)
<<
"evbuffer_add() failed"
;
return
-
1
;
}
Downstream
*
downstream
=
get_
top_
downstream
();
Downstream
*
downstream
=
get_downstream
();
if
(
downstream
)
{
downstream
->
set_response_state
(
Downstream
::
MSG_COMPLETE
);
}
...
...
@@ -522,32 +515,21 @@ bufferevent_event_cb HttpsUpstream::get_downstream_eventcb()
return
https_downstream_eventcb
;
}
void
HttpsUpstream
::
a
dd
_downstream
(
Downstream
*
downstream
)
void
HttpsUpstream
::
a
ttach
_downstream
(
Downstream
*
downstream
)
{
downstream_queue_
.
push_back
(
downstream
);
assert
(
!
downstream_
);
downstream_
=
downstream
;
}
void
HttpsUpstream
::
pop
_downstream
()
void
HttpsUpstream
::
delete
_downstream
()
{
downstream_queue_
.
pop_front
();
}
Downstream
*
HttpsUpstream
::
get_top_downstream
()
{
if
(
downstream_queue_
.
empty
())
{
return
0
;
}
else
{
return
downstream_queue_
.
front
();
}
delete
downstream_
;
downstream_
=
0
;
}
Downstream
*
HttpsUpstream
::
get_
last_downstream
()
Downstream
*
HttpsUpstream
::
get_
downstream
()
const
{
if
(
downstream_queue_
.
empty
())
{
return
0
;
}
else
{
return
downstream_queue_
.
back
();
}
return
downstream_
;
}
int
HttpsUpstream
::
on_downstream_header_complete
(
Downstream
*
downstream
)
...
...
src/shrpx_https_upstream.h
View file @
5597ee68
...
...
@@ -29,8 +29,6 @@
#include <stdint.h>
#include <deque>
extern
"C"
{
#include "http-parser/http_parser.h"
}
...
...
@@ -54,10 +52,9 @@ public:
virtual
bufferevent_data_cb
get_downstream_readcb
();
virtual
bufferevent_data_cb
get_downstream_writecb
();
virtual
bufferevent_event_cb
get_downstream_eventcb
();
void
add_downstream
(
Downstream
*
downstream
);
void
pop_downstream
();
Downstream
*
get_top_downstream
();
Downstream
*
get_last_downstream
();
void
attach_downstream
(
Downstream
*
downstream
);
void
delete_downstream
();
Downstream
*
get_downstream
()
const
;
int
error_reply
(
int
status_code
);
void
pause_read
(
IOCtrlReason
reason
);
...
...
@@ -73,7 +70,7 @@ private:
ClientHandler
*
handler_
;
http_parser
*
htp_
;
size_t
current_header_length_
;
std
::
deque
<
Downstream
*>
downstream_queue
_
;
Downstream
*
downstream
_
;
IOControl
ioctrl_
;
};
...
...
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