2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#1239] addressed comments

This commit is contained in:
Razvan Becheriu
2020-06-15 17:07:00 +03:00
parent 96745e24aa
commit 6fdb6e6539
2 changed files with 15 additions and 23 deletions

View File

@@ -15,6 +15,7 @@
#include <http/response_json.h>
#include <http/response_parser.h>
#include <util/multi_threading_mgr.h>
#include <util/unlock_guard.h>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
@@ -962,24 +963,18 @@ Connection::terminateInternal(const boost::system::error_code& ec,
}
}
// unlock mutex so that the callback can be safely processed.
if (MultiThreadingMgr::instance().getMode()) {
mutex_.unlock();
}
try {
// The callback should take care of its own exceptions but one
// never knows.
current_callback_(ec, response, parsing_error);
if (MultiThreadingMgr::instance().getMode()) {
UnlockGuard<std::mutex> lock(mutex_);
current_callback_(ec, response, parsing_error);
} else {
current_callback_(ec, response, parsing_error);
}
} catch (...) {
}
// lock mutex so that processing can continue.
if (MultiThreadingMgr::instance().getMode()) {
mutex_.lock();
}
// If we're not requesting connection persistence, we should close the socket.
// We're going to reconnect for the next transaction.
if (!current_request_->isPersistent()) {
@@ -989,21 +984,16 @@ Connection::terminateInternal(const boost::system::error_code& ec,
resetState();
}
// unlock mutex so that the next request can be safely processed.
if (MultiThreadingMgr::instance().getMode()) {
mutex_.unlock();
}
// Check if there are any requests queued for this connection and start
// another transaction if there is at least one.
ConnectionPoolPtr conn_pool = conn_pool_.lock();
if (conn_pool) {
conn_pool->processNextRequest(url_);
}
// lock mutex so that processing can continue.
if (MultiThreadingMgr::instance().getMode()) {
mutex_.lock();
if (MultiThreadingMgr::instance().getMode()) {
UnlockGuard<std::mutex> lock(mutex_);
conn_pool->processNextRequest(url_);
} else {
conn_pool->processNextRequest(url_);
}
}
}

View File

@@ -31,6 +31,7 @@ libkea_util_la_SOURCES += stopwatch_impl.cc stopwatch_impl.h
libkea_util_la_SOURCES += strutil.h strutil.cc
libkea_util_la_SOURCES += thread_pool.h
libkea_util_la_SOURCES += time_utilities.h time_utilities.cc
libkea_util_la_SOURCES += unlock_guard.h
libkea_util_la_SOURCES += versioned_csv_file.h versioned_csv_file.cc
libkea_util_la_SOURCES += watch_socket.cc watch_socket.h
libkea_util_la_SOURCES += watched_thread.cc watched_thread.h
@@ -77,6 +78,7 @@ libkea_util_include_HEADERS = \
strutil.h \
thread_pool.h \
time_utilities.h \
unlock_guard.h \
versioned_csv_file.h \
watch_socket.h \
watched_thread.h