From a70c936a3458b7e7bbe93b44a2fa18d3451576d6 Mon Sep 17 00:00:00 2001 From: sasgas Date: Thu, 14 Jul 2016 20:24:06 +0900 Subject: [PATCH] =?UTF-8?q?ADM-34=20socket::remote=5Fendpoint=20=EC=99=80?= =?UTF-8?q?=20socket::close=20=ED=95=A8=EC=88=98=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EA=B0=80=20=EB=B0=9C=EC=83=9D=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=9D=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amalgamate/crow_all.h | 18 ++++++++++++++---- include/http_connection.h | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/amalgamate/crow_all.h b/amalgamate/crow_all.h index 4c65e83c3..d78b43944 100644 --- a/amalgamate/crow_all.h +++ b/amalgamate/crow_all.h @@ -6592,9 +6592,16 @@ namespace crow } } - CROW_LOG_INFO << "Request: " << boost::lexical_cast(socket_.remote_endpoint()) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' ' + boost::system::error_code ec; + CROW_LOG_INFO << "Request: " << boost::lexical_cast(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) @@ -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(); @@ -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(); } @@ -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; } diff --git a/include/http_connection.h b/include/http_connection.h index 99e182cb5..fef78f27e 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -273,9 +273,15 @@ namespace crow } } - CROW_LOG_INFO << "Request: " << boost::lexical_cast(socket_.remote_endpoint()) << " " << this << " HTTP/" << parser_.http_major << "." << parser_.http_minor << ' ' + boost::system::error_code ec; + CROW_LOG_INFO << "Request: " << boost::lexical_cast(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) @@ -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(); @@ -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(); } @@ -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; }