summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-08-15 22:47:48 +0000
committerChris Wilson <chris+github@qwirx.com>2014-08-15 22:47:48 +0000
commite322f290450428f93ab95b0dfac296bd83aa20e0 (patch)
tree330646d554e3369c0348a0d26ed8a215f799b60e
parent4458bf17916973aeb9e99e9166070f645fb3295e (diff)
Add timeouts to command socket operations.
-rw-r--r--bin/bbackupctl/bbackupctl.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/bin/bbackupctl/bbackupctl.cpp b/bin/bbackupctl/bbackupctl.cpp
index e7b85fdc..256bace1 100644
--- a/bin/bbackupctl/bbackupctl.cpp
+++ b/bin/bbackupctl/bbackupctl.cpp
@@ -173,7 +173,7 @@ int main(int argc, const char *argv[])
// 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 @@ int main(int argc, const char *argv[])
" 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 @@ int main(int argc, const char *argv[])
"sync will never start!");
return 1;
}
-
}
break;
@@ -278,7 +277,8 @@ int main(int argc, const char *argv[])
// 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 @@ int main(int argc, const char *argv[])
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 @@ int main(int argc, const char *argv[])
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 @@ int main(int argc, const char *argv[])
{
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;