[Box Backup-commit] COMMIT r1428 - box/chris/merge/bin/bbackupd
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Thu, 22 Mar 2007 23:26:37 +0000
Author: chris
Date: 2007-03-22 23:26:37 +0000 (Thu, 22 Mar 2007)
New Revision: 1428
Modified:
box/chris/merge/bin/bbackupd/BackupDaemon.cpp
box/chris/merge/bin/bbackupd/BackupDaemon.h
Log:
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)
Modified: box/chris/merge/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.cpp 2007-03-22 23:22:30 UTC (rev 1427)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.cpp 2007-03-22 23:26:37 UTC (rev 1428)
@@ -119,8 +119,8 @@
// 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 @@
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::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);
}
Modified: box/chris/merge/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.h 2007-03-22 23:22:30 UTC (rev 1427)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.h 2007-03-22 23:26:37 UTC (rev 1428)
@@ -82,8 +82,9 @@
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 @@
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