#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>
}
}
- // 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()) {
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_);
+ }
}
}
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
strutil.h \
thread_pool.h \
time_utilities.h \
+ unlock_guard.h \
versioned_csv_file.h \
watch_socket.h \
watched_thread.h