[Box Backup-commit] COMMIT r3362 - box/trunk/bin/bbackupctl
subversion at boxbackup.org
subversion at boxbackup.org
Fri Aug 15 23:47:48 BST 2014
Author: chris
Date: 2014-08-15 23:47:48 +0100 (Fri, 15 Aug 2014)
New Revision: 3362
Modified:
box/trunk/bin/bbackupctl/bbackupctl.cpp
Log:
Add timeouts to command socket operations.
Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp
===================================================================
--- box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-08-15 22:47:44 UTC (rev 3361)
+++ box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-08-15 22:47:48 UTC (rev 3362)
@@ -173,7 +173,7 @@
// Wait for the configuration summary
std::string configSummary;
- if(!getLine.GetLine(configSummary))
+ if(!getLine.GetLine(configSummary, PROTOCOL_DEFAULT_TIMEOUT))
{
BOX_ERROR("Failed to receive configuration summary "
"from daemon");
@@ -206,7 +206,7 @@
" MaxUploadWait = " << maxUploadWait << " seconds");
std::string stateLine;
- if(!getLine.GetLine(stateLine) || getLine.IsEOF())
+ if(!getLine.GetLine(stateLine, PROTOCOL_DEFAULT_TIMEOUT) || getLine.IsEOF())
{
BOX_ERROR("Failed to receive state line from daemon");
return 1;
@@ -269,7 +269,6 @@
"sync will never start!");
return 1;
}
-
}
break;
@@ -278,7 +277,8 @@
// send a sync command
commandName = "force-sync";
std::string cmd = commandName + "\n";
- connection.Write(cmd.c_str(), cmd.size());
+ connection.Write(cmd.c_str(), cmd.size(),
+ PROTOCOL_DEFAULT_TIMEOUT);
connection.WriteAllBuffered();
if (currentState != 0)
@@ -291,19 +291,21 @@
default:
{
- // Normal case, just send the command given
- // plus a quit command.
+ // Normal case, just send the command given, plus a
+ // quit command.
std::string cmd = commandName + "\n";
- connection.Write(cmd.c_str(), cmd.size());
+ connection.Write(cmd.c_str(), cmd.size(),
+ PROTOCOL_DEFAULT_TIMEOUT);
}
// fall through
case NoCommand:
{
- // Normal case, just send the command given
- // plus a quit command.
+ // Normal case, just send the command given plus a
+ // quit command.
std::string cmd = "quit\n";
- connection.Write(cmd.c_str(), cmd.size());
+ connection.Write(cmd.c_str(), cmd.size(),
+ PROTOCOL_DEFAULT_TIMEOUT);
}
}
@@ -322,8 +324,9 @@
if(line == "start-sync")
{
// Send a quit command to finish nicely
- connection.Write("quit\n", 5);
-
+ connection.Write("quit\n", 5,
+ PROTOCOL_DEFAULT_TIMEOUT);
+
// And we're done
finished = true;
}
@@ -344,7 +347,8 @@
{
BOX_TRACE("Sync finished.");
// Send a quit command to finish nicely
- connection.Write("quit\n", 5);
+ connection.Write("quit\n", 5,
+ PROTOCOL_DEFAULT_TIMEOUT);
// And we're done
finished = true;
More information about the Boxbackup-commit
mailing list