Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f21307

Browse files
committed
Fixing issue with stoppage and cancellation when the server starts listening.
1 parent6a8ce11 commit1f21307

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎boost/network/protocol/http/server/async_server.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ namespace boost { namespace network { namespace http {
5555
// stop accepting new requests and let all the existing
5656
// handlers finish.
5757
stopping =true;
58-
acceptor.cancel();
58+
system::error_code ignored;
59+
acceptor.cancel(ignored);
5960
}
6061

6162
voidlisten() {
@@ -101,10 +102,15 @@ namespace boost { namespace network { namespace http {
101102
tcp::resolverresolver(service_);
102103
tcp::resolver::queryquery(address_, port_);
103104
tcp::endpoint endpoint = *resolver.resolve(query);
104-
acceptor.open(endpoint.protocol());
105-
acceptor.bind(endpoint);
105+
106+
system::error_code error;
107+
acceptor.open(endpoint.protocol(), error);
108+
if (error)return;
109+
acceptor.bind(endpoint, error);
110+
if (error)return;
106111
socket_options_base::acceptor_options(acceptor);
107-
acceptor.listen();
112+
acceptor.listen(asio::socket_base::max_connections, error);
113+
if (error)return;
108114
new_connection.reset(newconnection(service_, handler, thread_pool));
109115
acceptor.async_accept(new_connection->socket(),
110116
boost::bind(

‎boost/network/protocol/http/server/sync_server.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ namespace boost { namespace network { namespace http {
5757

5858
voidstop() {
5959
// stop accepting new connections and let all the existing handlers finish.
60-
acceptor_.cancel();
60+
system::error_code ignored;
61+
acceptor_.cancel(ignored);
62+
service_.stop();
6163
}
6264

6365
voidlisten() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp