summaryrefslogtreecommitdiff
path: root/bin/bbackupd
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-08-31 08:51:44 +0000
committerChris Wilson <chris+github@qwirx.com>2006-08-31 08:51:44 +0000
commit4db6a80d27444cf90ae41c6876c141f9c6db8284 (patch)
tree6654dabde9dc96fca10dd17fc6a4ed7b4ea815c1 /bin/bbackupd
parenta774a6288de6b346c5642edbeca4343a1c88512f (diff)
* bin/bbackupd/BackupDaemon.cpp
- Reinstate missing mReceivedCommandConn - Clean up exception handling
Diffstat (limited to 'bin/bbackupd')
-rw-r--r--bin/bbackupd/BackupDaemon.cpp53
1 files changed, 32 insertions, 21 deletions
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index 2b5a1b23..99abb01f 100644
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -262,6 +262,7 @@ void BackupDaemon::DeleteAllLocations()
#ifdef WIN32
void BackupDaemon::RunHelperThread(void)
{
+ this->mReceivedCommandConn = false;
mpCommandSocketInfo = new CommandSocketInfo;
WinNamedPipeStream& rSocket(mpCommandSocketInfo->mListeningSocket);
@@ -472,7 +473,7 @@ void BackupDaemon::Run()
}
catch(std::exception &e)
{
- ::syslog(LOG_ERR, "Internal error while "
+ ::syslog(LOG_WARNING, "Internal error while "
"closing command socket after "
"another exception: %s", e.what());
}
@@ -939,32 +940,24 @@ int BackupDaemon::UseScriptToSeeIfSyncAllowed()
}
}
- // Wait and then cleanup child process
- int status = 0;
- ::waitpid(pid, &status, 0);
}
catch(std::exception &e)
{
::syslog(LOG_ERR, "Internal error running SyncAllowScript: "
"%s", e.what());
- // Clean up
- if(pid != 0)
- {
- int status = 0;
- ::waitpid(pid, &status, 0);
- }
}
catch(...)
{
// Ignore any exceptions
// Log that something bad happened
::syslog(LOG_ERR, "Error running SyncAllowScript '%s'", conf.GetKeyValue("SyncAllowScript").c_str());
- // Clean up though
- if(pid != 0)
- {
- int status = 0;
- ::waitpid(pid, &status, 0);
- }
+ }
+
+ // Wait and then cleanup child process, if any
+ if (pid != 0)
+ {
+ int status = 0;
+ ::waitpid(pid, &status, 0);
}
return waitInSeconds;
@@ -1164,7 +1157,17 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla
{
::syslog(LOG_ERR, "Internal error in command socket thread: "
"%s", e.what());
- throw; // thread will die
+ // If an error occurs, and there is a connection active, just close that
+ // connection and continue. Otherwise, let the error propagate.
+ if(mpCommandSocketInfo->mpConnectedSocket.get() == 0)
+ {
+ throw; // thread will die
+ }
+ else
+ {
+ // Close socket and ignore error
+ CloseCommandConnection();
+ }
}
catch(...)
{
@@ -2345,10 +2348,16 @@ bool BackupDaemon::SerializeStoreObjectInfo(int64_t aClientStoreMarker, box_time
::syslog(LOG_INFO, "Saved store object info file '%s'",
StoreObjectInfoFile.c_str());
}
+ catch(std::exception &e)
+ {
+ ::syslog(LOG_ERR, "Internal error writing store object "
+ "info file (%s): %s",
+ StoreObjectInfoFile.c_str(), e.what());
+ }
catch(...)
{
- ::syslog(LOG_WARNING, "Requested store object info file '%s' "
- "not accessible or could not be created",
+ ::syslog(LOG_ERR, "Internal error writing store object "
+ "info file (%s): unknown error",
StoreObjectInfoFile.c_str());
}
@@ -2504,12 +2513,14 @@ bool BackupDaemon::DeserializeStoreObjectInfo(int64_t & aClientStoreMarker, box_
catch(std::exception &e)
{
::syslog(LOG_ERR, "Internal error reading store object "
- "info file: %s", e.what());
+ "info file (%s): %s",
+ StoreObjectInfoFile.c_str(), e.what());
}
catch(...)
{
::syslog(LOG_ERR, "Internal error reading store object "
- "info file: unknown error");
+ "info file (%s): unknown error",
+ StoreObjectInfoFile.c_str());
}
DeleteAllLocations();