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
d1f4dafd
Commit
d1f4dafd
authored
Feb 09, 2017
by
Tatsuhiro Tsujikawa
Committed by
GitHub
Feb 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #803 from clemahieu/asio_threading
Holding more shared_ptrs instead of raw ptrs
parents
36a20233
13fc54c6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
36 deletions
+38
-36
src/asio_client_session_impl.cc
src/asio_client_session_impl.cc
+22
-22
src/asio_client_session_tcp_impl.cc
src/asio_client_session_tcp_impl.cc
+5
-4
src/asio_client_session_tls_impl.cc
src/asio_client_session_tls_impl.cc
+11
-10
No files found.
src/asio_client_session_impl.cc
View file @
d1f4dafd
...
...
@@ -69,17 +69,17 @@ void session_impl::start_resolve(const std::string &host,
const
std
::
string
&
service
)
{
deadline_
.
expires_from_now
(
connect_timeout_
);
auto
self
=
this
->
shared_from_this
();
auto
self
=
shared_from_this
();
resolver_
.
async_resolve
({
host
,
service
},
[
this
,
self
](
const
boost
::
system
::
error_code
&
ec
,
[
self
](
const
boost
::
system
::
error_code
&
ec
,
tcp
::
resolver
::
iterator
endpoint_it
)
{
if
(
ec
)
{
not_connected
(
ec
);
self
->
not_connected
(
ec
);
return
;
}
start_connect
(
endpoint_it
);
s
elf
->
s
tart_connect
(
endpoint_it
);
});
deadline_
.
async_wait
(
std
::
bind
(
&
session_impl
::
handle_deadline
,
self
));
...
...
@@ -597,38 +597,38 @@ void session_impl::do_read() {
auto
self
=
this
->
shared_from_this
();
read_socket
([
this
,
self
](
const
boost
::
system
::
error_code
&
ec
,
read_socket
([
self
](
const
boost
::
system
::
error_code
&
ec
,
std
::
size_t
bytes_transferred
)
{
if
(
ec
)
{
if
(
!
should_stop
())
{
call_error_cb
(
ec
);
if
(
!
s
elf
->
s
hould_stop
())
{
self
->
call_error_cb
(
ec
);
}
stop
();
s
elf
->
s
top
();
return
;
}
{
callback_guard
cg
(
*
this
);
callback_guard
cg
(
*
self
);
auto
rv
=
nghttp2_session_mem_recv
(
se
ssion_
,
rb_
.
data
(),
bytes_transferred
);
nghttp2_session_mem_recv
(
se
lf
->
session_
,
self
->
rb_
.
data
(),
bytes_transferred
);
if
(
rv
!=
static_cast
<
ssize_t
>
(
bytes_transferred
))
{
call_error_cb
(
make_error_code
(
self
->
call_error_cb
(
make_error_code
(
static_cast
<
nghttp2_error
>
(
rv
<
0
?
rv
:
NGHTTP2_ERR_PROTO
)));
stop
();
s
elf
->
s
top
();
return
;
}
}
do_write
();
self
->
do_write
();
if
(
should_stop
())
{
stop
();
if
(
s
elf
->
s
hould_stop
())
{
s
elf
->
s
top
();
return
;
}
do_read
();
self
->
do_read
();
});
}
...
...
@@ -695,17 +695,17 @@ void session_impl::do_write() {
auto
self
=
this
->
shared_from_this
();
write_socket
(
[
this
,
self
](
const
boost
::
system
::
error_code
&
ec
,
std
::
size_t
n
)
{
[
self
](
const
boost
::
system
::
error_code
&
ec
,
std
::
size_t
n
)
{
if
(
ec
)
{
call_error_cb
(
ec
);
stop
();
self
->
call_error_cb
(
ec
);
s
elf
->
s
top
();
return
;
}
wblen_
=
0
;
writing_
=
false
;
self
->
wblen_
=
0
;
self
->
writing_
=
false
;
do_write
();
self
->
do_write
();
});
}
...
...
src/asio_client_session_tcp_impl.cc
View file @
d1f4dafd
...
...
@@ -37,19 +37,20 @@ session_tcp_impl::session_tcp_impl(
session_tcp_impl
::~
session_tcp_impl
()
{}
void
session_tcp_impl
::
start_connect
(
tcp
::
resolver
::
iterator
endpoint_it
)
{
auto
self
=
shared_from_this
();
boost
::
asio
::
async_connect
(
socket_
,
endpoint_it
,
[
this
](
const
boost
::
system
::
error_code
&
ec
,
[
self
](
const
boost
::
system
::
error_code
&
ec
,
tcp
::
resolver
::
iterator
endpoint_it
)
{
if
(
stopped
())
{
if
(
s
elf
->
s
topped
())
{
return
;
}
if
(
ec
)
{
not_connected
(
ec
);
self
->
not_connected
(
ec
);
return
;
}
connected
(
endpoint_it
);
self
->
connected
(
endpoint_it
);
});
}
...
...
src/asio_client_session_tls_impl.cc
View file @
d1f4dafd
...
...
@@ -43,37 +43,38 @@ session_tls_impl::session_tls_impl(
session_tls_impl
::~
session_tls_impl
()
{}
void
session_tls_impl
::
start_connect
(
tcp
::
resolver
::
iterator
endpoint_it
)
{
auto
self
=
std
::
static_pointer_cast
<
session_tls_impl
>
(
shared_from_this
());
boost
::
asio
::
async_connect
(
socket
(),
endpoint_it
,
[
this
](
const
boost
::
system
::
error_code
&
ec
,
socket
(),
endpoint_it
,
[
self
](
const
boost
::
system
::
error_code
&
ec
,
tcp
::
resolver
::
iterator
endpoint_it
)
{
if
(
stopped
())
{
if
(
s
elf
->
s
topped
())
{
return
;
}
if
(
ec
)
{
not_connected
(
ec
);
self
->
not_connected
(
ec
);
return
;
}
socket_
.
async_handshake
(
self
->
socket_
.
async_handshake
(
boost
::
asio
::
ssl
::
stream_base
::
client
,
[
this
,
endpoint_it
](
const
boost
::
system
::
error_code
&
ec
)
{
if
(
stopped
())
{
[
self
,
endpoint_it
](
const
boost
::
system
::
error_code
&
ec
)
{
if
(
s
elf
->
s
topped
())
{
return
;
}
if
(
ec
)
{
not_connected
(
ec
);
self
->
not_connected
(
ec
);
return
;
}
if
(
!
tls_h2_negotiated
(
socket_
))
{
not_connected
(
make_error_code
(
if
(
!
tls_h2_negotiated
(
s
elf
->
s
ocket_
))
{
self
->
not_connected
(
make_error_code
(
NGHTTP2_ASIO_ERR_TLS_NO_APP_PROTO_NEGOTIATED
));
return
;
}
connected
(
endpoint_it
);
self
->
connected
(
endpoint_it
);
});
});
}
...
...
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