From eee4907406d6292b215a2d7453cfaa144a3da336 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 22 Mar 2007 23:26:37 +0000 Subject: Add a new notification constant, NotifyEvent_BackupError, for use when an exception occurs during the backup. Make bbackupd notify sysadmin when an exception occurs during the backup, using this error code, and the notification string "backup-error". Change NotifyEvent__MAX to be one greater than the highest notification constant, makes code more maintainable. (refs #3) --- bin/bbackupd/BackupDaemon.cpp | 16 ++++++++++++---- bin/bbackupd/BackupDaemon.h | 7 ++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index 0ab676eb..a56003d1 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -119,8 +119,8 @@ BackupDaemon::BackupDaemon() // Only ever one instance of a daemon SSLLib::Initialise(); - // Initialise notifcation sent status - for(int l = 0; l <= NotifyEvent__MAX; ++l) + // Initialise notification sent status + for(int l = 0; l < NotifyEvent__MAX; ++l) { mNotificationsSent[l] = false; } @@ -878,6 +878,8 @@ void BackupDaemon::Run2() else { // Not restart/terminate, pause and retry + // Notify administrator + NotifySysadmin(NotifyEvent_BackupError); SetState(State_Error); BOX_ERROR("Exception caught (" << errorString @@ -2013,11 +2015,17 @@ void BackupDaemon::TouchFileInWorkingDir(const char *Filename) // -------------------------------------------------------------------------- void BackupDaemon::NotifySysadmin(int Event) { - static const char *sEventNames[] = {"store-full", "read-error", 0}; + static const char *sEventNames[] = + { + "store-full", + "read-error", + "backup-error", + 0 + }; BOX_TRACE("BackupDaemon::NotifySysadmin() called, event = " << Event); - if(Event < 0 || Event > NotifyEvent__MAX) + if(Event < 0 || Event >= NotifyEvent__MAX) { THROW_EXCEPTION(BackupStoreException, BadNotifySysadminEventCode); } diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h index cf812001..64b06949 100644 --- a/bin/bbackupd/BackupDaemon.h +++ b/bin/bbackupd/BackupDaemon.h @@ -82,8 +82,9 @@ public: enum { NotifyEvent_StoreFull = 0, - NotifyEvent_ReadError = 1, - NotifyEvent__MAX = 1 + NotifyEvent_ReadError, + NotifyEvent_BackupError, + NotifyEvent__MAX // When adding notifications, remember to add strings to NotifySysadmin() }; void NotifySysadmin(int Event); @@ -177,7 +178,7 @@ private: CommandSocketInfo *mpCommandSocketInfo; // Stop notifications being repeated. - bool mNotificationsSent[NotifyEvent__MAX + 1]; + bool mNotificationsSent[NotifyEvent__MAX]; // Unused entries in the root directory wait a while before being deleted box_time_t mDeleteUnusedRootDirEntriesAfter; // time to delete them -- cgit v1.2.3