diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-12-28 22:03:23 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-12-28 22:03:23 +0000 |
commit | 1c1872a295a8f624feda363b9edb366da97798c6 (patch) | |
tree | cbf33eb2ca84250f31c8b134a77b150d48e3d4b8 /bin | |
parent | a0e488cdab1907167d2f02a1b88706aea7f44a79 (diff) |
Add missing timeouts on command socket writes.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index 4ca92aad..34dfba61 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -2062,7 +2062,7 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla conf.GetKeyValueInt("MaxUploadWait") << "\nstate " << mState << "\n"; mapCommandSocketInfo->mpConnectedSocket->Write( - hello.str()); + hello.str(), timeout); // Set the timeout to something very small, so we don't wait too long on waiting // for any incoming data @@ -2082,7 +2082,8 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla } // Ping the remote side, to provide errors which will mean the socket gets closed - mapCommandSocketInfo->mpConnectedSocket->Write("ping\n", 5); + mapCommandSocketInfo->mpConnectedSocket->Write("ping\n", 5, + timeout); // Wait for a command or something on the socket std::string command; @@ -2132,7 +2133,9 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla // Send a response back? if(sendResponse) { - mapCommandSocketInfo->mpConnectedSocket->Write(sendOK?"ok\n":"error\n", sendOK?3:6); + std::string response = sendOK ? "ok\n" : "error\n"; + mapCommandSocketInfo->mpConnectedSocket->Write( + response, timeout); } // Set timeout to something very small, so this just checks for data which is waiting @@ -2257,8 +2260,8 @@ void BackupDaemon::SendSyncStartOrFinish(bool SendStart) try { message += "\n"; - mapCommandSocketInfo->mpConnectedSocket->Write( - message.c_str(), message.size()); + mapCommandSocketInfo->mpConnectedSocket->Write(message, + 1); // short timeout, it's overlapped } catch(std::exception &e) { @@ -2989,7 +2992,8 @@ void BackupDaemon::SetState(int State) // Something connected to the command socket, tell it about the new state try { - mapCommandSocketInfo->mpConnectedSocket->Write(msg.str()); + mapCommandSocketInfo->mpConnectedSocket->Write(msg.str(), + 1); // very short timeout, it's overlapped anyway } catch(ConnectionException &ce) { |