diff options
author | Chris Wilson <chris+github@qwirx.com> | 2006-12-03 10:40:26 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2006-12-03 10:40:26 +0000 |
commit | e0a80f0da840849a5cdb38bcfea7a7e240a2aa2d (patch) | |
tree | ee3c2b1327a16bf04f4f1fa9507af88d7d438df0 /bin/bbackupd/BackupClientContext.cpp | |
parent | 7a47551a8c2eba625a1f32c4c7dd61015ebeaa36 (diff) |
Moved KeepAlive timer to BackupClientContext object.
Made timeout initialisation non-static, and a property of the context
object. (perhaps should be in rParams, I know).
(refs #3, refs #9)
Diffstat (limited to 'bin/bbackupd/BackupClientContext.cpp')
-rw-r--r-- | bin/bbackupd/BackupClientContext.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index cb6d8bc7..516c88bc 100644 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -67,6 +67,7 @@ BackupClientContext::BackupClientContext mStorageLimitExceeded(false), mpExcludeFiles(0), mpExcludeDirs(0), + mKeepAliveTimer(0), mbIsManaged(false) { } @@ -495,21 +496,17 @@ bool BackupClientContext::FindFilename(int64_t ObjectID, int64_t ContainingDirec return true; } -// maximum time to spend diffing -static int sMaximumDiffTime = 600; -// maximum time of SSL inactivity (keep-alive interval) -static int sKeepAliveTime = 0; - void BackupClientContext::SetMaximumDiffingTime(int iSeconds) { - sMaximumDiffTime = iSeconds < 0 ? 0 : iSeconds; - TRACE1("Set maximum diffing time to %d seconds\n", sMaximumDiffTime); + mMaximumDiffingTime = iSeconds < 0 ? 0 : iSeconds; + TRACE1("Set maximum diffing time to %d seconds\n", mMaximumDiffingTime); } void BackupClientContext::SetKeepAliveTime(int iSeconds) { - sKeepAliveTime = iSeconds < 0 ? 0 : iSeconds; - TRACE1("Set keep-alive time to %d seconds\n", sKeepAliveTime); + mKeepAliveTime = iSeconds < 0 ? 0 : iSeconds; + TRACE1("Set keep-alive time to %d seconds\n", mKeepAliveTime); + mKeepAliveTimer = Timer(mKeepAliveTime); } // -------------------------------------------------------------------------- @@ -544,7 +541,8 @@ void BackupClientContext::UnManageDiffProcess() // // Function // Name: BackupClientContext::DoKeepAlive() -// Purpose: Does something inconsequential over the SSL link to keep it up +// Purpose: Check whether it's time to send a KeepAlive +// message over the SSL link, and if so, send it. // Created: 04/19/2005 // // -------------------------------------------------------------------------- @@ -552,19 +550,26 @@ void BackupClientContext::DoKeepAlive() { if (!mpConnection) { - ::syslog(LOG_ERR, "DoKeepAlive() called with no connection!"); + return; + } + + if (mKeepAliveTime == 0) + { return; } + if (!mKeepAliveTimer.HasExpired()) + { + return; + } + + TRACE0("KeepAliveTime reached, sending keep-alive message\n"); mpConnection->QueryGetIsAlive(); + + mKeepAliveTimer = Timer(mKeepAliveTime); } int BackupClientContext::GetMaximumDiffingTime() { - return sMaximumDiffTime; -} - -int BackupClientContext::GetKeepAliveTime() -{ - return sKeepAliveTime; + return mMaximumDiffingTime; } |