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
5c2ca287
Commit
5c2ca287
authored
Apr 13, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asio: client: Call error_cb on error occurred in do_read and do_write
Fixes GH-207
parent
a8ea86cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
src/asio_client_session_impl.cc
src/asio_client_session_impl.cc
+16
-8
src/asio_client_session_impl.h
src/asio_client_session_impl.h
+1
-0
No files found.
src/asio_client_session_impl.cc
View file @
5c2ca287
...
...
@@ -89,10 +89,7 @@ void session_impl::connected(tcp::resolver::iterator endpoint_it) {
}
void
session_impl
::
not_connected
(
const
boost
::
system
::
error_code
&
ec
)
{
auto
&
error_cb
=
on_error
();
if
(
error_cb
)
{
error_cb
(
ec
);
}
call_error_cb
(
ec
);
}
void
session_impl
::
on_connect
(
connect_cb
cb
)
{
connect_cb_
=
std
::
move
(
cb
);
}
...
...
@@ -103,6 +100,14 @@ const connect_cb &session_impl::on_connect() const { return connect_cb_; }
const
error_cb
&
session_impl
::
on_error
()
const
{
return
error_cb_
;
}
void
session_impl
::
call_error_cb
(
const
boost
::
system
::
error_code
&
ec
)
{
auto
&
error_cb
=
on_error
();
if
(
!
error_cb
)
{
return
;
}
error_cb
(
ec
);
}
namespace
{
int
on_begin_headers_callback
(
nghttp2_session
*
session
,
const
nghttp2_frame
*
frame
,
void
*
user_data
)
{
...
...
@@ -308,10 +313,7 @@ bool session_impl::setup_session() {
auto
rv
=
nghttp2_session_client_new
(
&
session_
,
callbacks
,
this
);
if
(
rv
!=
0
)
{
auto
&
error_cb
=
on_error
();
if
(
error_cb
)
{
error_cb
(
make_error_code
(
static_cast
<
nghttp2_error
>
(
rv
)));
}
call_error_cb
(
make_error_code
(
static_cast
<
nghttp2_error
>
(
rv
)));
return
false
;
}
...
...
@@ -528,6 +530,7 @@ void session_impl::do_read() {
std
::
size_t
bytes_transferred
)
{
if
(
ec
)
{
if
(
ec
.
value
()
==
boost
::
asio
::
error
::
operation_aborted
)
{
call_error_cb
(
ec
);
shutdown_socket
();
}
return
;
...
...
@@ -540,6 +543,8 @@ void session_impl::do_read() {
nghttp2_session_mem_recv
(
session_
,
rb_
.
data
(),
bytes_transferred
);
if
(
rv
!=
static_cast
<
ssize_t
>
(
bytes_transferred
))
{
call_error_cb
(
make_error_code
(
static_cast
<
nghttp2_error
>
(
rv
<
0
?
rv
:
NGHTTP2_ERR_PROTO
)));
shutdown_socket
();
return
;
}
...
...
@@ -577,6 +582,7 @@ void session_impl::do_write() {
const
uint8_t
*
data
;
auto
n
=
nghttp2_session_mem_send
(
session_
,
&
data
);
if
(
n
<
0
)
{
call_error_cb
(
make_error_code
(
static_cast
<
nghttp2_error
>
(
n
)));
shutdown_socket
();
return
;
}
...
...
@@ -606,6 +612,8 @@ void session_impl::do_write() {
write_socket
([
this
](
const
boost
::
system
::
error_code
&
ec
,
std
::
size_t
n
)
{
if
(
ec
)
{
call_error_cb
(
ec
);
shutdown_socket
();
return
;
}
...
...
src/asio_client_session_impl.h
View file @
5c2ca287
...
...
@@ -97,6 +97,7 @@ protected:
private:
bool
should_stop
()
const
;
bool
setup_session
();
void
call_error_cb
(
const
boost
::
system
::
error_code
&
ec
);
boost
::
asio
::
io_service
&
io_service_
;
tcp
::
resolver
resolver_
;
...
...
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