summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/Backends/NetworkUserBackend.cpp24
-rw-r--r--src/Core/ThreadManager.cpp7
2 files changed, 25 insertions, 6 deletions
diff --git a/src/Common/Backends/NetworkUserBackend.cpp b/src/Common/Backends/NetworkUserBackend.cpp
index 20deba6..1e06a78 100644
--- a/src/Common/Backends/NetworkUserBackend.cpp
+++ b/src/Common/Backends/NetworkUserBackend.cpp
@@ -84,6 +84,8 @@ void NetworkUserBackend::UserUpdateRequest::sendRequest() {
}
boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "ListUsers", timestamp));
application->getRequestManager()->sendRequest(connection, request);
@@ -119,6 +121,8 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend::
}
boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "GetUserInfo", "uid", uid, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -149,6 +153,8 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long
}
boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetUserInfo", name, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -179,6 +185,8 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const st
}
boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "ListUserGroups", "uid", uid, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -209,6 +217,8 @@ boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getUserGro
}
boost::shared_ptr<const std::map<unsigned long, GroupInfo> > NetworkUserBackend::getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "ListGroups", timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -240,6 +250,8 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > NetworkUserBackend:
}
boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "GetGroupInfo", "gid", gid, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -264,6 +276,8 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfo(unsigned lon
}
boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetGroupInfo", name, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -288,6 +302,8 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const
}
boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "ListGroupUsers", "gid", gid, timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -318,6 +334,8 @@ boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getGroupUs
}
boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > NetworkUserBackend::getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "GetFullUserGroupList", timestamp));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -353,6 +371,8 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > NetworkUse
void NetworkUserBackend::addUser(const UserInfo &userInfo) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<UserAddRequest> request(new UserAddRequest(application, userInfo));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -363,6 +383,8 @@ void NetworkUserBackend::addUser(const UserInfo &userInfo) throw(Core::Exception
}
void NetworkUserBackend::updateUser(unsigned long uid, const Common::UserInfo &userInfo) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<UserUpdateRequest> request(new UserUpdateRequest(application, uid, userInfo));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
@@ -373,6 +395,8 @@ void NetworkUserBackend::updateUser(unsigned long uid, const Common::UserInfo &u
}
void NetworkUserBackend::deleteUser(unsigned long uid) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "DeleteUser", "uid", uid));
application->getRequestManager()->sendRequest(connection, request);
request->wait();
diff --git a/src/Core/ThreadManager.cpp b/src/Core/ThreadManager.cpp
index ecb6031..773ef23 100644
--- a/src/Core/ThreadManager.cpp
+++ b/src/Core/ThreadManager.cpp
@@ -57,11 +57,6 @@ void ThreadManager::workerFunc() {
}
void ThreadManager::detach() {
- if(isThisMainThread()) {
- application->log(Logger::CRITICAL, "Tried to detach main thread! This is just WRONG!");
- return;
- }
-
{
boost::lock_guard<boost::mutex> lock(runLock);
if(!running)
@@ -70,7 +65,7 @@ void ThreadManager::detach() {
threadLock.lock();
- if(workerThread->get_id() == boost::this_thread::get_id()) {// Already detached?
+ if(workerThread->get_id() == boost::this_thread::get_id()) {// Already detached or no worker thread?
threads.insert(std::make_pair(boost::this_thread::get_id(), workerThread));
workerThread.reset(new boost::thread(std::mem_fun(&ThreadManager::workerFunc), this));