diff options
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 53 |
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(); |