[Box Backup-dev] COMMIT r843 - box/chris/retry-debug/bin/bbstored
Ben Summers
boxbackup-dev@fluffy.co.uk
Thu, 31 Aug 2006 12:54:45 +0100
Probably not important as you can't use the server for real, but this
stops the server from being able to detect and prevent two writeable
connections at once. Should be documented somewhere at least, in
comments here. I presume the store is marked as "for tests only" on
Win32?
Ben
On 31 Aug 2006, at 09:12, subversion@fluffy.co.uk wrote:
> Author: chris
> Date: 2006-08-31 09:12:47 +0100 (Thu, 31 Aug 2006)
> New Revision: 843
>
> Modified:
> box/chris/retry-debug/bin/bbstored/BackupContext.cpp
> Log:
> * bin/bbstored/BackupContext.cpp
> - Removed locking on Win32, there is no housekeeping process to lock
> against
> - Open files with O_BINARY on Win32
> - Fixed a cosmetic spelling mistake in a comment
> - Unlink file later on Windows, since we can't do it while it's open
>
>
> Modified: box/chris/retry-debug/bin/bbstored/BackupContext.cpp
> ===================================================================
> --- box/chris/retry-debug/bin/bbstored/BackupContext.cpp 2006-08-31
> 08:12:00 UTC (rev 842)
> +++ box/chris/retry-debug/bin/bbstored/BackupContext.cpp 2006-08-31
> 08:12:47 UTC (rev 843)
> @@ -125,6 +125,7 @@
> //
> ----------------------------------------------------------------------
> ----
> bool BackupContext::AttemptToGetWriteLock()
> {
> +#ifndef WIN32
> // Make the filename of the write lock file
> std::string writeLockFile;
> StoreStructure::MakeWriteLockFilename(mStoreRoot, mStoreDiscSet,
> writeLockFile);
> @@ -150,7 +151,7 @@
>
> } while(!gotLock && tries > 0);
> }
> -
> +
> if(gotLock)
> {
> // Got the lock, mark as not read only
> @@ -158,6 +159,10 @@
> }
>
> return gotLock;
> +#else // WIN32
> + // no housekeeping process, we do have the lock
> + return true;
> +#endif // !WIN32
> }
>
>
> @@ -453,13 +458,21 @@
> try
> {
> // Open it twice
> +#ifdef WIN32
> + FileStream diff(tempFn.c_str(),
> + O_RDWR | O_CREAT | O_BINARY);
> + FileStream diff2(tempFn.c_str(),
> + O_RDWR | O_BINARY);
> +#else
> FileStream diff(tempFn.c_str(), O_RDWR | O_CREAT | O_EXCL);
> FileStream diff2(tempFn.c_str(), O_RDONLY);
> - // Unlink it immediately, so it definately goes away
> +
> + // Unlink it immediately, so it definitely goes away
> if(::unlink(tempFn.c_str()) != 0)
> {
> THROW_EXCEPTION(CommonException, OSFileError);
> }
> +#endif
>
> // Stream the incoming diff to this temporary file
> if(!rFile.CopyStreamTo(diff, BACKUP_STORE_TIMEOUT))
> @@ -508,6 +521,14 @@
> ::unlink(tempFn.c_str());
> throw;
> }
> +
> +#ifdef WIN32
> + // we can't delete the file while it's open, above
> + if(::unlink(tempFn.c_str()) != 0)
> + {
> + THROW_EXCEPTION(CommonException, OSFileError);
> + }
> +#endif
> }
>
> // Get the blocks used
>
> _______________________________________________
> Boxbackup-dev mailing list
> Boxbackup-dev@fluffy.co.uk
> http://lists.warhead.org.uk/mailman/listinfo/boxbackup-dev