From e63bfdce883c80ee856668fc8cccdf3f5740fb6b Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Mon, 24 Nov 2008 22:57:07 +0000 Subject: fixed syncing, config & showtables --- src/syncClient.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/syncClient.cpp') diff --git a/src/syncClient.cpp b/src/syncClient.cpp index 5d4be45..8170990 100644 --- a/src/syncClient.cpp +++ b/src/syncClient.cpp @@ -44,7 +44,7 @@ SyncClient::SyncClient(std::string hostname,std::string port) -:hostname_( hostname),port_(port) +:hostname_( hostname),port_(port),missing_chars(-1) { } @@ -70,26 +70,33 @@ void SyncClient::run() if (error) throw boost::system::system_error(error); - for (;;) + try { - boost::array buf; - boost::system::error_code error; + for (;;) + { + boost::array buf; + boost::system::error_code error; - size_t len = socket.read_some(boost::asio::buffer(buf), error); + size_t len = socket.read_some(boost::asio::buffer(buf), error); - if (error == boost::asio::error::eof) - break; // Connection closed cleanly by peer. - else if (error) - throw boost::system::system_error(error); // Some other error. + if (error == boost::asio::error::eof) + break; // Connection closed cleanly by peer. + else if (error) + throw boost::system::system_error(error); // Some other error. - OnRawData(buf.data(), len); + OnRawData(buf.data(), len); + } + } + catch (std::exception& e) + { + cLog.msg(Log::PRIO_NOTICE) << e.what() << std::endl; } } sleep(10); } catch (std::exception& e) { - std::cerr << e.what() << std::endl; + cLog.msg(Log::PRIO_NOTICE) << e.what() << std::endl; } } @@ -113,7 +120,7 @@ void SyncClient::OnRawData(const char *buf,size_t len) std::stringstream tmp; tmp.write(buffer,6); tmp>>missing_chars; -// cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion length from " << GetRemoteHostname() <<" "<