Commit 10eaa838 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5260] Added commentary about making copies of function handlers.

parent d4cf144a
...@@ -50,6 +50,7 @@ HttpConnection::~HttpConnection() { ...@@ -50,6 +50,7 @@ HttpConnection::~HttpConnection() {
void void
HttpConnection::close() { HttpConnection::close() {
request_timer_.cancel();
socket_.close(); socket_.close();
} }
...@@ -67,6 +68,9 @@ HttpConnection::stopThisConnection() { ...@@ -67,6 +68,9 @@ HttpConnection::stopThisConnection() {
void void
HttpConnection::asyncAccept() { HttpConnection::asyncAccept() {
// Create instance of the callback. It is safe to pass the local instance
// of the callback, because the underlying boost functions make copies
// as needed.
HttpAcceptorCallback cb = boost::bind(&HttpConnection::acceptorCallback, HttpAcceptorCallback cb = boost::bind(&HttpConnection::acceptorCallback,
shared_from_this(), shared_from_this(),
boost::asio::placeholders::error); boost::asio::placeholders::error);
...@@ -83,6 +87,9 @@ void ...@@ -83,6 +87,9 @@ void
HttpConnection::doRead() { HttpConnection::doRead() {
try { try {
TCPEndpoint endpoint; TCPEndpoint endpoint;
// Create instance of the callback. It is safe to pass the local instance
// of the callback, because the underlying boost functions make copies
// as needed.
SocketCallback cb(boost::bind(&HttpConnection::socketReadCallback, SocketCallback cb(boost::bind(&HttpConnection::socketReadCallback,
shared_from_this(), shared_from_this(),
boost::asio::placeholders::error, boost::asio::placeholders::error,
...@@ -99,6 +106,9 @@ void ...@@ -99,6 +106,9 @@ void
HttpConnection::doWrite() { HttpConnection::doWrite() {
try { try {
if (!output_buf_.empty()) { if (!output_buf_.empty()) {
// Create instance of the callback. It is safe to pass the local instance
// of the callback, because the underlying boost functions make copies
// as needed.
SocketCallback cb(boost::bind(&HttpConnection::socketWriteCallback, SocketCallback cb(boost::bind(&HttpConnection::socketWriteCallback,
shared_from_this(), shared_from_this(),
boost::asio::placeholders::error, boost::asio::placeholders::error,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment