fixed deadlock in logger

This commit is contained in:
BadAix 2015-08-08 10:19:44 +02:00
parent e35e724110
commit e45eb08be6
5 changed files with 8 additions and 8 deletions

View file

@ -1,4 +1,4 @@
VERSION = 0.2.92 VERSION = 0.2.93
TARGET = snapclient TARGET = snapclient
SHELL = /bin/bash SHELL = /bin/bash
@ -53,7 +53,6 @@ uninstall:
@if [[ `systemctl` =~ -\.mount ]]; then \ @if [[ `systemctl` =~ -\.mount ]]; then \
$(MAKE) uninstallsystemd; \ $(MAKE) uninstallsystemd; \
elif [[ `/sbin/init --version` =~ upstart ]]; then \ elif [[ `/sbin/init --version` =~ upstart ]]; then \
echo upstart => sysv; \
$(MAKE) uninstallsysv; \ $(MAKE) uninstallsysv; \
elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then \ elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then \
$(MAKE) uninstallsysv; \ $(MAKE) uninstallsysv; \

View file

@ -55,7 +55,7 @@ int Log::sync()
else if (priority_ == kOut) else if (priority_ == kOut)
std::cout << Timestamp() << " [out] " << buffer_.c_str() << std::flush; std::cout << Timestamp() << " [out] " << buffer_.c_str() << std::flush;
else if (priority_ == kErr) else if (priority_ == kErr)
std::cerr << Timestamp() << " [err] " << buffer_.c_str() << std::flush; std::cout << Timestamp() << " [err] " << buffer_.c_str() << std::flush;
else else
{ {
std::cout << Timestamp() << " [" << std::to_string(priority_) << "] " << buffer_.c_str() << std::flush; std::cout << Timestamp() << " [" << std::to_string(priority_) << "] " << buffer_.c_str() << std::flush;

View file

@ -1,4 +1,4 @@
VERSION = 0.2.92 VERSION = 0.2.93
TARGET = snapserver TARGET = snapserver
SHELL = /bin/bash SHELL = /bin/bash

View file

@ -139,7 +139,7 @@ void PipeReader::worker()
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
std::cerr << "Exception: " << e.what() << std::endl; logE << "Exception: " << e.what() << std::endl;
} }
} }
} }

View file

@ -49,6 +49,7 @@ void ServerSession::start()
void ServerSession::stop() void ServerSession::stop()
{ {
std::unique_lock<std::mutex> mlock(mutex_);
active_ = false; active_ = false;
try try
{ {
@ -62,13 +63,13 @@ void ServerSession::stop()
} }
if (readerThread_) if (readerThread_)
{ {
logO << "joining readerThread\n"; logD << "joining readerThread\n";
readerThread_->join(); readerThread_->join();
delete readerThread_; delete readerThread_;
} }
if (writerThread_) if (writerThread_)
{ {
logO << "joining writerThread\n"; logD << "joining writerThread\n";
writerThread_->join(); writerThread_->join();
delete writerThread_; delete writerThread_;
} }
@ -79,7 +80,7 @@ void ServerSession::stop()
readerThread_ = NULL; readerThread_ = NULL;
writerThread_ = NULL; writerThread_ = NULL;
socket_ = NULL; socket_ = NULL;
logO << "ServerSession stopped\n"; logD << "ServerSession stopped\n";
} }