Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon S3 backend support #9

Open
wants to merge 250 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
d155938
Normalize all the line endings
qris May 15, 2017
0e7bee4
Tell Git to treat .cpp files as text too.
qris May 15, 2017
f786bcc
Tell Git to ignore some more generated files
qris May 15, 2017
be46ea2
Add Boost to Travis build environment, and OSX builds
qris May 15, 2017
61930b3
Update versions of dependencies for Windows unibuild, add Boost
qris May 18, 2017
9560039
Install executables in test tree after building, not during "make ins…
qris May 18, 2017
1fad457
Fix build on SmartOS by switching back to GNU Make
qris Jan 23, 2017
8f1d2ef
Hopefully fix test/raidfile on Solaris.
qris Jan 26, 2017
692eae7
Fix emulated readdir() d_type to return DT_FILE or DT_DIR like Unix does
qris Dec 22, 2016
88bcc2f
Relax timings on test_changing_client_store_marker_pauses_daemon
qris May 22, 2017
848dacf
Enable compiler error on classes with non-virtual destructors.
qris Oct 31, 2015
2c952ad
Remove unused code: BoxDebugTrace() and BoxDebug_printf()
qris Feb 19, 2017
0458cd3
Create a job object during Windows tests to kill abandoned daemons
qris Dec 26, 2016
5da656c
Add a platform-independent implementation of box_strtoui64
qris May 30, 2017
7e7ba9b
Move S3BackupFileSystem class into its own file.
qris Oct 16, 2015
83d68a4
Improve exception handling in S3Simulator, S3Client and HTTPServer.
qris Nov 28, 2015
2ef4e5e
Travis build script: add extra debugging.
qris Nov 5, 2016
bcaffc0
Fix overloaded virtual function warnings.
qris Nov 9, 2016
897f429
Refactor test/s3store to make check_new_account_info() reusable.
qris Nov 9, 2016
e0c3560
Whitespace cleanup
qris Nov 9, 2016
16f2d6b
Fix warning about snprintf() being deprecated on Windows.
qris Nov 11, 2016
0b9713c
Refactor common HTTP header handling
qris Nov 13, 2016
b6ded1a
Fix incorrect timeout calculation in GetLine
qris Nov 17, 2016
64f1adb
Add tests for S3Simulator and S3Client
qris Nov 18, 2016
19032c5
Add tests for S3Simulator and S3Client
qris Jul 29, 2017
1ef9b6c
Add MD5DigestStream and test
qris Nov 18, 2016
3463fcb
Refactor S3Simulator to better support merge of SimpleDB support
qris Nov 18, 2016
34adb89
Move BackupStoreObjectDump.cpp to lib/backupstore
qris Nov 21, 2016
5df14f5
Remove unused intercept code from testbbackupd.
qris Oct 15, 2015
65197c0
Make IOStream::CopyStreamTo honour timeout
qris Oct 13, 2015
91592fd
Add an assertion to CollectInBufferStream
qris Nov 23, 2016
8501574
Remove unwanted prototype for HeadObject()
qris Nov 23, 2016
5bd70fc
Allow control of network timeout in HTTPResponse::Send()
qris Nov 23, 2016
b294747
Log every request made using S3Client (for now)
qris Nov 23, 2016
36f0d51
Add initial (non-functioning) keepalive support in S3Client
qris Aug 2, 2017
733e443
Fix confusion about URIs and paths in S3 filesystem
qris Jun 2, 2017
76e44c2
Fix quoting of CXXFLAGS and LDFLAGS in Makefiles
qris Jun 2, 2017
1442c91
Replace RAND_pseudo_bytes with RAND_bytes
qris Jun 3, 2017
8afc332
Move BackupStoreAccountControl code to BackupAccountControl file
qris Nov 25, 2016
a7db6fc
Add Boost, needed for XML support in S3Simulator and S3Client
qris Nov 22, 2016
cdfba68
Declare Base64 decoding array as signed char
qris Jun 12, 2017
cf7c111
Make narrowing conversions an error
qris Jun 14, 2017
4f03228
Use a named enum type for DirReadType (RaidFileRead::ReadDirectoryCon…
qris Jun 25, 2017
ca7c5dd
Add comments to explain the three S3Client constructors
qris Jun 25, 2017
1fce16a
Enable and fix raidfile intercepts on Mac OSX
qris Jun 25, 2017
3cd6d9a
Fix check for a working struct dirent.d_type
qris Jun 25, 2017
0a8430d
Fix exit status from tests: could previously return 0 even after fail…
qris Feb 26, 2017
aeece4f
Allow 1 extra second in test_store_error_reporting
qris Feb 27, 2017
7f9685c
Fix delete of incomplete type in BackupAccountControl.h
qris Mar 1, 2017
490ad64
Log time taken by each test case in a test suite.
qris Mar 2, 2017
64ff56f
Add support for RelWithDebInfo builds using CMake
qris Mar 7, 2017
09f6d2a
CMake: make readline support configurable, not automatic
qris Mar 24, 2017
90abd71
Remove link and unlink macros on Windows.
qris Oct 30, 2016
32de046
Win32 build: upgrade to _WIN32_WINNT 0x600 (WinXP and above)
qris Mar 27, 2017
0b6e71d
Refactor winsock initialisation on Windows
qris Feb 19, 2017
131f38b
Fix compile warnings about printf format strings in DebugMemLeakFinder
qris Apr 17, 2017
659e389
Reduce precision of common timer test
qris Feb 26, 2017
90a5d65
Increase logging level and add timestamps in testcommon
qris Jun 20, 2017
8bf0050
Stop Git from normalising line endings
qris Jun 19, 2017
1ac9ea8
Build Win32/64 binary packages automatically
qris Jul 3, 2017
0e35730
Update banner text, and shorten compiled-in Git version numbers
qris Apr 17, 2017
2272480
bbstoreaccounts: add support for standard command-line logging options
qris Apr 17, 2017
19b2f59
Make generated files depend on their generators under CMake
qris Mar 30, 2017
f1a29fc
Whitespace fixes
qris Jul 3, 2017
05e0605
Remove Xamarin to remove 500 lines of junk from build logs
qris Jul 3, 2017
273b38f
Reorder lines in appveyor.yml to match actual execution order
qris Jul 3, 2017
d0a3a56
Reduce AppVeyor build verbosity by passing extra args to sub-CMake
qris Jul 3, 2017
e88c365
Disable DEBUG to reduce CMake build verbosity on AppVeyor
qris Jul 3, 2017
d12b15d
Lock store while corrupting it in test/backupstorefix
qris May 14, 2017
9da58d5
Improve error messages when PCRE detection fails (or is abused)
qris May 25, 2017
24386d9
Remove MEMLEAKFINDER_NOT_A_LEAK from FileStream
qris Dec 17, 2017
ddbd18f
Win32: add experimental stack backtraces with symbol lookup
qris Mar 27, 2017
0915553
Modify command-line -L option to override log level for a specific file
qris Mar 31, 2017
affc81a
Use filename where exception was thrown in DumpStackBacktrace
qris Mar 31, 2017
054ae87
Enable backtraces and timestamps in all tests when building with CMake
qris Mar 31, 2017
61587bd
Use the correct preprocessor define for release builds
qris Apr 4, 2017
c0e4722
Show IP address as well as hostname for ServerException::SocketOpenError
qris Apr 16, 2017
f4f0261
test/backupstorefix: tag bbstoreaccounts check output in tests
qris Jul 5, 2017
c603841
Add support for M4 CXX flag detection in CMakeLists
qris Feb 27, 2017
bece5fe
Store and log full stack traces for leaked memory allocations
qris Jan 6, 2017
4d7e654
Increase default verbosity in some timing tests
qris Jul 7, 2017
d5c59cf
Detect which debugger to use in t-gdb scripts: lldb or gdb
qris Dec 2, 2016
5f3b823
Don't add CXXFLAGS to CFLAGS
qris Jun 25, 2017
2d86ee0
Perl buildsystem: add test prepare targets
qris Apr 17, 2017
80ab4a9
Rename BackupStoreAccountsControl to BackupStoreAccountControl
qris Jul 8, 2017
0355674
Add missing implementations of RaidBackupFileSystem methods
qris Jul 8, 2017
2338aa8
Refactor BackupStoreAccountControl to be for a specific account ID
qris Jul 8, 2017
bea63fd
Remove debugging code to list files during test_multiple_uploads
qris Jul 10, 2017
e64803b
Whitespace and comment cleanup
qris Jul 29, 2017
4c5c0b7
Custom build system: fix autogen dependencies
qris Jul 15, 2017
4768ca4
Make ObjectExists and BackupStoreCheck use object_exists_t enum
qris Jul 18, 2017
8ec9aaa
Add GetTempDirPath() for portability
qris Jul 18, 2017
4c89e59
Fix include ordering in testcommon.cpp
qris Jul 19, 2017
3a8ea56
Refactor testcommon to split into independent tests
qris Jul 19, 2017
15b0a19
Add force parameter to RemovePrefix and RemoveSuffix
qris Jul 19, 2017
011fd40
Remove BackupStoreContext::ReceivedFinishCommand
qris Jul 20, 2017
e3a8dd4
Refactor BackupStoreContext::GetBackupStoreInfo
qris Jul 22, 2017
3199cd8
Enable C++0x support
qris Jul 22, 2017
c49632e
Refactor to create BackupFileSystem::GetBackupStoreInfo
qris Jul 23, 2017
7c5110b
Refactor BackupFileSystem::GetLock()
qris Jul 23, 2017
b19bbca
Refactor test code into process_is_running()
qris Jul 23, 2017
af96b96
Implement compare_lists and test_equal_maps in lib/common/Test.cpp
qris Jul 24, 2017
fae96d2
Add static method HTTPQueryDecoder::URLEncode
qris Jul 26, 2017
5382916
Add query parameter editing and encoding to HTTPRequest
qris Jul 26, 2017
d578213
Add support for virtualhost names in S3Client
qris Jul 27, 2017
28c66f0
Add simulator and client for SimpleDB
qris Jul 27, 2017
ea99dca
Add support for S3-compatible ETag headers to S3Simulator
qris Jul 29, 2017
4437907
Add support for If-None-Match header to S3Client and S3Simulator
qris Aug 2, 2017
0dac53b
Rename setup_test_bbackupd() in test/bbackupd
qris Jul 30, 2017
1b88a18
Make GetBlockSize() use BackupFileSystem
qris Aug 3, 2017
a18a235
Protocol generator: record last error message received
qris Aug 3, 2017
53d731f
Improve error message on hostname lookup failure
qris Aug 4, 2017
97cf1c4
Make narrowing conversions an error
qris Jun 14, 2017
ee0dfb5
Fix incorrect detection of the need to intercept lxstat
qris Jun 24, 2017
71de481
Increase precision of timing on Windows.
qris Aug 4, 2017
6ba7e2b
Switch PCRE back to an official release
qris Aug 5, 2017
92d7bce
Remove BoxBackup install step from Windows unibuild
qris Aug 5, 2017
21f5ce8
Upgrade to OpenSSL 1.0.2l
qris Aug 6, 2017
c7423fb
Improve exception messages from RaidFileWrite
qris Aug 6, 2017
6f030c0
Travis CI: exclude (don't build) tags created by AppVeyor
qris Aug 7, 2017
255d17d
Add ResponseCodeString shortcut to HTTPResponse
qris Aug 7, 2017
edad605
Add option to include parameters in HTTPRequest::GetRequestURI
qris Aug 7, 2017
72d40fd
Fix FileExists in Utils.cpp
qris Aug 7, 2017
9249079
Add ListBucket command support to S3Simulator and S3Client
qris Aug 7, 2017
2573947
Fix negative estimated remaining time due to 64-bit integer overflow …
qris Jan 12, 2016
d6b23e6
Add support for the HEAD and DELETE methods to the S3Simulator and S3…
qris Aug 12, 2017
8ac3ab1
Enable memory testing under Darwin, as it does work now
qris Jan 6, 2017
ada15fb
Rename local variable
qris Aug 13, 2017
f979af8
Fix conflict over unlocked refcount DB
qris Aug 13, 2017
c647181
Refactor BackupStoreRefCountDatabase to an abstract interface
qris Aug 13, 2017
32dece4
Move management of BackupStoreRefCountDatabase into BackupFileSystem
qris Aug 13, 2017
754c6c7
Initial refactor of BackupAccountControl to use BackupFileSystem
qris Aug 17, 2017
6d61b9b
Enable compiler warning -Werror=overloaded-virtual, and fix
qris Aug 17, 2017
83036e9
Refactor HousekeepStoreAccount to use BackupFileSystem
qris Aug 17, 2017
44d8fce
Refactor BackupStoreCheck to use BackupFileSystem, part 1
qris Aug 26, 2017
ef25b53
Refactor BackupStoreCheck to use BackupFileSystem, part 2
qris Aug 27, 2017
024d312
Refactor BackupStoreCheck to use BackupFileSystem, part 3
qris Aug 27, 2017
e9682cb
Refactor BackupStoreCheck to use BackupFileSystem, part 4
qris Aug 27, 2017
5258d2b
Refactor BackupStoreCheck to use BackupFileSystem, part 5
qris Aug 27, 2017
5c1a665
Refactor BackupStoreCheck to use BackupFileSystem, part 6
qris Aug 28, 2017
0de8946
Refactor BackupStoreCheck to use BackupFileSystem, part 7
qris Aug 28, 2017
1d8269f
Refactor BackupStoreCheck to use BackupFileSystem, part 8
qris Aug 28, 2017
d84e189
Rename some local variables in BackupStoreCheck
qris Aug 28, 2017
f83b27a
Add configuration for S3 local cache directory
qris Sep 4, 2017
dcdee22
Fix repeated calls to TryGetLock() when already holding lock
qris Sep 4, 2017
cac70db
Implement RefCountDatabase methods in S3BackupFileSystem
qris Sep 4, 2017
1a2c7d2
Fix writeback of refcount databases on BackupFileSystem destruction
qris Sep 4, 2017
33ce005
Wait for housekeeping to finish before bbstored exits
qris Sep 4, 2017
7161374
Remove useless Get/Put/HeadObject methods from S3BackupFileSystem
qris Sep 5, 2017
3a72f64
Refactor BackupAccountControl to use BackupFileSystem
qris Sep 6, 2017
1ce7b43
Refactor BackupStoreFile::VerifyStream from write to read side
qris Sep 7, 2017
6b1e778
Improve exception handling in single-process servers
qris Oct 29, 2017
a9d7404
Fix a long-standing bug in the set_refcount() test helper function
qris Sep 18, 2017
0ed71ac
Add extra refcount checks to test_server_housekeeping
qris Sep 18, 2017
1487b4c
Refactor BackupStoreContext to use BackupFileSystem
qris Sep 18, 2017
fb9e846
Enable and fix warnings in infrastructure/makebuildenv.pl
qris Sep 22, 2017
a453cea
Fix Makefile dependency tracking of configured files
qris Sep 18, 2017
c99e1b2
Refactor GetLine
qris Sep 22, 2017
8a40a1f
Implement placement operator delete
qris Sep 24, 2017
a687d9c
Enable support for S3 virtual hosts in BackupAccountControl
qris Sep 24, 2017
5ffd6fd
Properly implement S3BackupFileSystem::GetPermanentRefCountDatabase
qris Sep 24, 2017
3b777f7
Remove always-false assertion in S3BackupFileSystem::GetDirectory
qris Sep 24, 2017
63cff12
Add store test helpers for specialised tests
qris Sep 24, 2017
475c789
Make BackupStoreContext::ClearDirectoryCache() public
qris Sep 24, 2017
effcc7e
Test that 100-continue headers are sent and received correctly
qris Oct 7, 2017
8a3982e
Test that the S3 backend properly implements basic commands
qris Oct 7, 2017
c3f0df0
Completely disable syslog logging in tests
qris Oct 31, 2017
35521cf
Remove *.vcxproj.user from disposable CMake build directory
qris Dec 21, 2016
2406323
Add support for TcpNice on OSX, remove on Windows
qris Nov 10, 2017
6076f17
Move functions around to reduce diffs to s3_support
qris Nov 10, 2017
121663e
Fix compile error in BSD getopt_long.cpp
qris Nov 10, 2017
547dd73
Fix SimpleDB timeouts: should be in milliseconds, not seconds
qris Nov 9, 2017
130ea83
ServerStream and test/backupstore: improve comments slightly
qris Nov 8, 2017
3473b86
S3Simulator: add some TRACE logging to help debug 100-continue responses
qris Nov 8, 2017
643f4ae
Increase timeouts in S3Client to help with debugging
qris Nov 8, 2017
c0c1286
SocketStream: use THROW_SOCKET_ERROR for better messages on Windows
qris Oct 31, 2017
d319a6e
Enable overriding log level by category as well as filename
qris Oct 31, 2017
ac71706
Windows syslog() emulation: improve error messages
qris Oct 31, 2017
60257e2
Fix rare crash while tearing down S3BackupFileSystem
qris Oct 29, 2017
aabd78c
Increase time allowed for backup in test_store_error_reporting
qris Nov 20, 2017
ad86838
Enable precedence warnings as errors (-Werror=parentheses)
qris Nov 20, 2017
61995c3
Remove invalid use of null references (undefined behaviour)
qris Nov 20, 2017
5b9ed71
Enable errors on unused private fields (-Werror=unused-private-field)
qris Nov 22, 2017
d5a4c6d
Make BackupAccountControl throw exceptions on lock failure
qris Nov 22, 2017
d7fa177
bbstoreaccounts: more refactoring to support non-raidfile backends
qris Nov 22, 2017
087c66b
Remove unused #includes from BackupCommands.cpp
qris Nov 26, 2017
11e1e7a
Add a constant for WRITE_LOCK_FILENAME
qris Nov 26, 2017
65d0eab
Fix S3BackupFileSystem::GetAccountIdentifier() exception
qris Dec 1, 2017
48e1ae9
Generalise BackupFileSystem::GetLock and reuse it
qris Nov 14, 2017
5a54934
Only replace getopt on Windows, not any other platform
qris Nov 30, 2017
ef40223
Enable -Werror=writable-strings and fix one such error
qris Nov 30, 2017
7cf8a0c
Fix ProtocolError single-argument (subtype only) constructor
qris Nov 30, 2017
26bfe3f
Fix build order for targets which depend on auto-generated files
qris Nov 30, 2017
3febe9d
Check for both SocketReadError and SocketWriteError
qris Dec 7, 2017
d98c657
Fix GCC warnings about -Wno-* flags
qris Dec 8, 2017
1a96f95
Fix cleanup of backupstore specialised tests
qris Nov 19, 2017
fb2af31
Port test_server_housekeeping to BackupFileSystem
qris Dec 8, 2017
0f72030
Fix 5f6680520574f15b97f92e151d93efc40be0f100
qris Dec 9, 2017
637849a
Port test_directory_parent_entry_tracks_directory_size to BackupFileS…
qris Dec 9, 2017
36f0586
Add detailed logging of BackupFileSystem locks
qris Nov 14, 2017
3785800
Fix missing define causing unnecessary stat() on Windows
qris Dec 11, 2017
53c3731
Remove duplicate QDBM logging macros from BackupClientInodeToIDMap.cpp
qris Mar 18, 2010
3d52e36
Enable detailed logging of locking in test/backupstorefix
qris Nov 14, 2017
524e110
Allow using LogLevelOverrideByFileGuard as a guard
qris Nov 14, 2017
40323aa
Remove BackupStoreAccounts::LockAccount
qris Dec 12, 2017
5cfd43b
test/common: use setup and teardown macros on each test case
qris Dec 17, 2017
b6f0544
Add tests for exclusivity of locking
qris Dec 17, 2017
bf5fe9c
Mark master branch builds as full releases (not pre-releases) on GitHub
qris Dec 17, 2017
b9678dd
Add S3 BackupFileSystem locking using SimpleDB
qris Dec 26, 2017
4fdd776
Build 64-bit OpenSSL in Windows superbuild
qris Dec 27, 2017
7ae24cd
BackupStoreContext: improve log messages regarding the cache
qris Jan 1, 2018
b800c84
BackupAccountControl: silence exceptions during CreateAccount
qris Jan 1, 2018
f88f0e0
Remove remaining calls to check_num_files() without a BackupFileSystem
qris Jan 1, 2018
6d1953e
Refactor BackupStoreInfo to remove legacy RaidFile support
qris Jan 1, 2018
6f3920c
Run test_account_limits_respected on S3 BackupFileSystem
qris Jan 2, 2018
f3fb6a6
Add a test for S3BackupFileSystem and its RevisionID calculation
qris Jan 2, 2018
b4f597a
Refactor testbackupstorefix to reduce code duplication
qris Jan 2, 2018
511ecc7
testbackupstorepatch: improve debugging messages
qris Jan 2, 2018
46e96d2
Port test/backupstorepatch to use BackupFileSystem
qris Jan 8, 2018
ef12d71
Suppress exception messages in LineBuffer::GetLine
qris Nov 17, 2017
ab72aa6
Clear up Daemon command-line arguments -D and -F
qris Nov 9, 2017
3fa9848
Eliminate conditional code for Windows file handles from NamedLock
qris Dec 21, 2016
5db2393
Improve NamedLock code readability, reliability and logging
qris Apr 22, 2017
32352ce
Add support for OpenSSL 1.1 and replace deprecated function calls
qris Jun 3, 2017
405ec5e
Improve logging in test/basicserver to help debug FreeBSD test failures
qris Jan 13, 2018
0cd3f61
Move check for -Werror=narrowing to join other -Werror checks
qris Jan 14, 2018
ad635c6
Add protocol logging to help debug test/basicserver timeouts on FreeBSD
qris Jan 15, 2018
2429fdc
Remove unused #includes from BackupStoreContext.cpp
qris Jan 15, 2018
cab1b71
Add some comments
qris Jan 15, 2018
d5b8f38
Improve exception messages when configuration keys are missing or inv…
qris Jan 12, 2016
1a8d472
check_reference_counts: add assertion that ExpectedRefCounts has corr…
qris Jan 19, 2018
67ead0d
Wait for housekeeping to finish before bbstored exits
qris Sep 4, 2017
069627c
Remove full stops from ends of exception messages, for consistency
qris Jan 19, 2018
ec81363
RaidFile: allow creating a new file with refcount == 0
qris Jan 20, 2018
4a83ecc
Add support for general file locking in FileStream
qris Jan 20, 2018
d671450
Convert RaidFileWrite to use FileStream to write stripes
qris Jan 20, 2018
616ad76
Compile out test_memory_leak_detection if leak detection is disabled
qris Jan 21, 2018
edcde8e
Remove unnecessary mainhelper catch for BoxException specifically
qris Jan 21, 2018
d1a5226
Remove MemLeakFindOn/Off #includes from Utils.h
qris Jan 21, 2018
007ec3b
Remove unnecessary dependencies from modules.txt
qris Jan 21, 2018
8ee03a0
Actually pass test options (e.g. timing) to test command
qris Jan 21, 2018
c12f691
Merge branch 'master' into s3_support_merge
qris Jan 21, 2018
2bfbf29
Add more logging to test/basicserver for FreeBSD timeouts
qris Jan 21, 2018
98c9865
Use BackupFileSystem locking in testbackupstorepatch
qris Oct 12, 2016
477c795
Add support for S3 commands to bbstoreaccounts utility
qris Jan 22, 2018
ee454a8
Add missing #includes to BackupFileSystem.cpp
qris Jan 24, 2018
858f0ed
Remove unnecessary friend class
qris Jan 24, 2018
7a8f626
Add missing #include in BackupStoreCheck.h
qris Jan 24, 2018
9a53a08
Don't bother with HAVE_DEFINE_PRAGMA, it's unnecessary and doesn't al…
qris Dec 27, 2016
88311ff
Specialise test_multiple_uploads, but only for testbackupstore so far
qris Jan 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert RaidFileWrite to use FileStream to write stripes
Enable exclusive locking of stripe files on all platforms, not just Windows and
O_EXLOCK.
  • Loading branch information
qris committed Dec 17, 2017
commit d6714507bd965b4b37a335328e9ce07dfad21fbb
3 changes: 1 addition & 2 deletions lib/common/CommonException.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ InvalidConfiguration 52 Some required values are missing or incorrect in the c
IOStreamTimedOut 53 A network operation timed out
SignalReceived 54 The function call returned because the process received a signal
NamedLockFailed 55 Failed to acquire a named lock
FileLockFailed 56 Failed to acquire a lock on a file for an unexpected reason
FileLockingConflict 57 The file is already locked by another process
FileLockingConflict 56 The file is already locked by another process
99 changes: 52 additions & 47 deletions lib/common/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
// --------------------------------------------------------------------------

#include "Box.h"

#include <errno.h>

#ifdef HAVE_FCNTL_G
#include <fcntl.h>
#endif

#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif

#include "FileStream.h"
#include "CommonException.h"
#include "Logging.h"

#include <errno.h>

#include "MemLeakFindOn.h"

// --------------------------------------------------------------------------
Expand All @@ -24,11 +33,11 @@
// Created: 2003/07/31
//
// --------------------------------------------------------------------------
FileStream::FileStream(const std::string& rFilename, int flags, int mode,
FileStream::FileStream(const std::string& mFileName, int flags, int mode,
lock_mode_t lock_mode)
: mOSFileHandle(INVALID_FILE),
mIsEOF(false),
mFileName(rFilename)
mFileName(mFileName)
{
OpenFile(flags, mode, lock_mode);
}
Expand Down Expand Up @@ -144,63 +153,59 @@ void FileStream::OpenFile(int flags, int mode, lock_mode_t lock_mode)
}
}

try
{
bool lock_failed = false;
bool lock_failed = false;

#ifdef BOX_LOCK_TYPE_FLOCK
BOX_TRACE("Trying to lock " << rFilename << " " << lock_message);
if(::flock(fd, (lock_mode == SHARED ? LOCK_SH : LOCK_EX) | LOCK_NB) != 0)
BOX_TRACE("Trying to lock " << mFileName << " " << lock_message);
if(::flock(mOSFileHandle, (lock_mode == SHARED ? LOCK_SH : LOCK_EX) | LOCK_NB) != 0)
{
Close();

if(errno == EWOULDBLOCK)
{
if(errno == EWOULDBLOCK)
{
lock_failed = true;
}
else
{
THROW_SYS_FILE_ERROR("Failed to lock lockfile " << lock_method_name,
mFileName, CommonException, OSFileError);
}
lock_failed = true;
}
else
{
THROW_SYS_FILE_ERROR("Failed to lock lockfile " << lock_method_name,
mFileName, CommonException, OSFileError);
}
}
#elif defined BOX_LOCK_TYPE_F_SETLK || defined BOX_LOCK_TYPE_F_OFD_SETLK
struct flock desc;
desc.l_type = (lock_mode == SHARED ? F_RDLCK : F_WRLCK);
desc.l_whence = SEEK_SET;
desc.l_start = 0;
desc.l_len = 0;
desc.l_pid = 0;
BOX_TRACE("Trying to lock " << mFileName << " " << lock_message);
struct flock desc;
desc.l_type = (lock_mode == SHARED ? F_RDLCK : F_WRLCK);
desc.l_whence = SEEK_SET;
desc.l_start = 0;
desc.l_len = 0;
desc.l_pid = 0;
BOX_TRACE("Trying to lock " << mFileName << " " << lock_message);
# if defined BOX_LOCK_TYPE_F_OFD_SETLK
if(::fcntl(fd, F_OFD_SETLK, &desc) != 0)
if(::fcntl(mOSFileHandle, F_OFD_SETLK, &desc) != 0)
# else // BOX_LOCK_TYPE_F_SETLK
if(::fcntl(fd, F_SETLK, &desc) != 0)
if(::fcntl(mOSFileHandle, F_SETLK, &desc) != 0)
# endif
{
Close();

if(errno == EAGAIN)
{
if(errno == EAGAIN)
{
lock_failed = true;
}
else
{
THROW_SYS_FILE_ERROR("Failed to lock lockfile " << lock_method_name,
mFileName, CommonException, OSFileError);
}
lock_failed = true;
}
#endif

if(lock_failed)
else
{
// We failed to lock the file, which means that it's locked by someone else.
// Need to throw a specific exception that's expected by NamedLock, which
// should just return false in this case (and only this case).
THROW_EXCEPTION_MESSAGE(CommonException, FileLockingConflict,
BOX_FILE_MESSAGE(mFileName, "File already locked by another process"));
THROW_SYS_FILE_ERROR("Failed to lock lockfile " << lock_method_name,
mFileName, CommonException, OSFileError);
}
}
catch(BoxException &e)
#endif

if(lock_failed)
{
THROW_FILE_ERROR("Failed to lock file: " << e.what(), mFileName,
CommonException, FileLockFailed);
// We failed to lock the file, which means that it's locked by someone else.
// Need to throw a specific exception that's expected by NamedLock, which
// should just return false in this case (and only this case).
THROW_EXCEPTION_MESSAGE(CommonException, FileLockingConflict,
BOX_FILE_MESSAGE(mFileName, "File already locked by another process"));
}
}

Expand Down
11 changes: 0 additions & 11 deletions lib/common/NamedLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@

#include "Box.h"

#include <fcntl.h>
#include <errno.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef HAVE_FLOCK
#include <sys/file.h>
#endif

#include "CommonException.h"
#include "NamedLock.h"
#include "Utils.h"
Expand Down
42 changes: 18 additions & 24 deletions lib/raidfile/RaidFileWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,12 @@ void RaidFileWrite::TransformToRaidStorage()
// Then open them all for writing (in strict order)
try
{
#if HAVE_DECL_O_EXLOCK
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK | O_BINARY)> stripe1(stripe1FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK | O_BINARY)> stripe2(stripe2FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK | O_BINARY)> parity(parityFilenameW.c_str());
#else
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_BINARY)> stripe1(stripe1FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_BINARY)> stripe2(stripe2FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_BINARY)> parity(parityFilenameW.c_str());
#endif
FileStream stripe1(stripe1FilenameW, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0755,
FileStream::EXCLUSIVE);
FileStream stripe2(stripe2FilenameW, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0755,
FileStream::EXCLUSIVE);
FileStream parity(parityFilenameW, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0755,
FileStream::EXCLUSIVE);

// Then... read in data...
int bytesRead = -1;
Expand Down Expand Up @@ -615,10 +612,7 @@ void RaidFileWrite::TransformToRaidStorage()
}

// Write block
if(::write(parity, parityBuffer, parityWriteSize) != parityWriteSize)
{
THROW_EXCEPTION(RaidFileException, OSError)
}
parity.Write(parityBuffer, parityWriteSize);
}

// Write stripes
Expand All @@ -629,11 +623,14 @@ void RaidFileWrite::TransformToRaidStorage()
int toWrite = (l == (blocksToDo - 1))
?(bytesRead - ((blocksToDo-1)*blockSize))
:blockSize;
if(::write(((l&1)==0)?stripe1:stripe2, writeFrom, toWrite) != toWrite)
if((l & 1) == 0)
{
stripe1.Write(writeFrom, toWrite);
}
else
{
THROW_SYS_FILE_ERROR("Failed to write to permanent RAID file",
writeFilename, RaidFileException, OSError);
}
stripe2.Write(writeFrom, toWrite);
}

// Next block
writeFrom += blockSize;
Expand All @@ -642,6 +639,7 @@ void RaidFileWrite::TransformToRaidStorage()
// Count of blocks done
blocksDone += blocksToDo;
}

// Error on read?
if(bytesRead == -1)
{
Expand All @@ -661,12 +659,8 @@ void RaidFileWrite::TransformToRaidStorage()
{
ASSERT(sizeof(writeFileStat.st_size) <= sizeof(RaidFileRead::FileSizeType));
RaidFileRead::FileSizeType sw = box_hton64(writeFileStat.st_size);
ASSERT((::lseek(parity, 0, SEEK_CUR) % blockSize) == 0);
if(::write(parity, &sw, sizeof(sw)) != sizeof(sw))
{
THROW_SYS_FILE_ERROR("Failed to write to file", writeFilename,
RaidFileException, OSError);
}
ASSERT((parity.GetPosition() % blockSize) == 0);
parity.Write(&sw, sizeof(sw));
}

// Then close the written files (note in reverse order of opening)
Expand All @@ -675,7 +669,7 @@ void RaidFileWrite::TransformToRaidStorage()
stripe1.Close();

#ifdef WIN32
// Must delete before renaming
// Must delete any existing file before renaming over it
#define CHECK_UNLINK(file) \
{ \
if (EMU_UNLINK(file) != 0 && errno != ENOENT) \
Expand Down