Skip to content

Commit

Permalink
ADM-34 socket::remote_endpoint 와 socket::close 함수에서 예외가 발생할 수 있음.
Browse files Browse the repository at this point in the history
  • Loading branch information
sasgas committed Jul 14, 2016
1 parent 5bdbca0 commit a70c936
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
18 changes: 14 additions & 4 deletions amalgamate/crow_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -6592,9 +6592,16 @@ namespace crow
}
}

CROW_LOG_INFO << "Request: " << boost::lexical_cast<std::string>(socket_.remote_endpoint()) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' '
boost::system::error_code ec;
CROW_LOG_INFO << "Request: " << boost::lexical_cast<std::string>(socket_.remote_endpoint(ec)) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' '
<< method_name(req.method) << " " << req.url;

if (ec)
{
is_invalid_request = true;
res = response(400);
}


need_to_call_after_handlers_ = false;
if (!is_invalid_request)
Expand Down Expand Up @@ -6769,7 +6776,8 @@ namespace crow
{
cancel_deadline_timer();
parser_.done();
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
is_reading = false;
CROW_LOG_DEBUG << this << " from read(1)";
check_destroy();
Expand Down Expand Up @@ -6799,7 +6807,8 @@ namespace crow
{
if (close_connection_)
{
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
CROW_LOG_DEBUG << this << " from write(1)";
check_destroy();
}
Expand Down Expand Up @@ -6838,7 +6847,8 @@ namespace crow
{
return;
}
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
});
CROW_LOG_DEBUG << this << " timer added: " << timer_cancel_key_.first << ' ' << timer_cancel_key_.second;
}
Expand Down
17 changes: 13 additions & 4 deletions include/http_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,15 @@ namespace crow
}
}

CROW_LOG_INFO << "Request: " << boost::lexical_cast<std::string>(socket_.remote_endpoint()) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' '
boost::system::error_code ec;
CROW_LOG_INFO << "Request: " << boost::lexical_cast<std::string>(socket_.remote_endpoint(ec)) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' '
<< method_name(req.method) << " " << req.url;

if (ec)
{
is_invalid_request = true;
res = response(400);
}

need_to_call_after_handlers_ = false;
if (!is_invalid_request)
Expand Down Expand Up @@ -451,7 +457,8 @@ namespace crow
{
cancel_deadline_timer();
parser_.done();
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
is_reading = false;
CROW_LOG_DEBUG << this << " from read(1)";
check_destroy();
Expand Down Expand Up @@ -481,7 +488,8 @@ namespace crow
{
if (close_connection_)
{
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
CROW_LOG_DEBUG << this << " from write(1)";
check_destroy();
}
Expand Down Expand Up @@ -520,7 +528,8 @@ namespace crow
{
return;
}
socket_.close();
boost::system::error_code ec2;
socket_.close(ec2);
});
CROW_LOG_DEBUG << this << " timer added: " << timer_cancel_key_.first << ' ' << timer_cancel_key_.second;
}
Expand Down

0 comments on commit a70c936

Please sign in to comment.