Changeset 2127
- Timestamp:
- 04/04/2008 23:11:45 (4 years ago)
- Location:
- box/trunk
- Files:
-
- 64 edited
-
bin/bbackupd/BackupClientContext.cpp (modified) (4 diffs)
-
bin/bbackupd/BackupClientContext.h (modified) (2 diffs)
-
bin/bbackupd/BackupClientDirectoryRecord.cpp (modified) (2 diffs)
-
bin/bbackupd/BackupDaemon.cpp (modified) (5 diffs)
-
bin/bbackupd/Win32ServiceFunctions.cpp (modified) (2 diffs)
-
bin/bbackupd/bbackupd-config.in (modified) (1 diff)
-
bin/bbackupquery/BackupQueries.cpp (modified) (7 diffs)
-
bin/bbackupquery/bbackupquery.cpp (modified) (2 diffs)
-
bin/bbstoreaccounts/bbstoreaccounts.cpp (modified) (3 diffs)
-
bin/bbstored/BBStoreDHousekeeping.cpp (modified) (1 diff)
-
bin/bbstored/BackupContext.cpp (modified) (1 diff)
-
bin/bbstored/bbstored-config.in (modified) (1 diff)
-
configure.ac (modified) (3 diffs)
-
documentation/bbackupctl.xml (modified) (4 diffs)
-
documentation/bbackupquery.xml (modified) (4 diffs)
-
documentation/bbstoreaccounts.xml (modified) (4 diffs)
-
documentation/bbstored-certs.xml (modified) (4 diffs)
-
documentation/bbstored-config.xml (modified) (3 diffs)
-
documentation/raidfile-config.xml (modified) (4 diffs)
-
lib/backupclient/BackupClientRestore.cpp (modified) (4 diffs)
-
lib/backupclient/BackupDaemonConfigVerify.cpp (modified) (2 diffs)
-
lib/backupclient/BackupStoreFileDiff.cpp (modified) (8 diffs)
-
lib/backupclient/BackupStoreFilenameClear.cpp (modified) (2 diffs)
-
lib/backupclient/BackupStoreObjectDump.cpp (modified) (2 diffs)
-
lib/backupstore/BackupStoreCheck.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreCheck2.cpp (modified) (9 diffs)
-
lib/backupstore/BackupStoreCheckData.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreConfigVerify.cpp (modified) (2 diffs)
-
lib/common/Box.h (modified) (2 diffs)
-
lib/common/BoxTime.cpp (modified) (1 diff)
-
lib/common/Configuration.cpp (modified) (23 diffs)
-
lib/common/Configuration.h (modified) (3 diffs)
-
lib/common/DebugMemLeakFinder.cpp (modified) (3 diffs)
-
lib/common/EventWatchFilesystemObject.cpp (modified) (5 diffs)
-
lib/common/FileStream.cpp (modified) (6 diffs)
-
lib/common/FileStream.h (modified) (1 diff)
-
lib/common/Guards.h (modified) (1 diff)
-
lib/common/Logging.h (modified) (3 diffs)
-
lib/common/PartialReadStream.cpp (modified) (1 diff)
-
lib/common/Utils.cpp (modified) (2 diffs)
-
lib/common/Utils.h (modified) (1 diff)
-
lib/compress/Compress.h (modified) (2 diffs)
-
lib/compress/CompressStream.cpp (modified) (1 diff)
-
lib/crypto/CipherContext.cpp (modified) (4 diffs)
-
lib/intercept/intercept.cpp (modified) (2 diffs)
-
lib/raidfile/RaidFileController.cpp (modified) (1 diff)
-
lib/raidfile/RaidFileWrite.cpp (modified) (3 diffs)
-
lib/server/Daemon.cpp (modified) (6 diffs)
-
lib/server/Daemon.h (modified) (1 diff)
-
lib/server/ProtocolUncertainStream.cpp (modified) (1 diff)
-
lib/server/ServerControl.h (modified) (1 diff)
-
lib/server/ServerStream.h (modified) (2 diffs)
-
lib/server/ServerTLS.h (modified) (1 diff)
-
lib/server/SocketListen.h (modified) (13 diffs)
-
lib/server/SocketStream.cpp (modified) (11 diffs)
-
test/backupdiff/testbackupdiff.cpp (modified) (2 diffs)
-
test/basicserver/testbasicserver.cpp (modified) (2 diffs)
-
test/bbackupd/testbbackupd.cpp (modified) (4 diffs)
-
test/bbackupd/testfiles/bbackupd-temploc.conf (modified) (1 diff)
-
test/bbackupd/testfiles/bbackupd.conf.in (modified) (1 diff)
-
test/bbackupd/testfiles/bbstored.conf (modified) (1 diff)
-
test/common/testcommon.cpp (modified) (3 diffs)
-
test/compress/testcompress.cpp (modified) (1 diff)
-
test/raidfile/testraidfile.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupd/BackupClientContext.cpp
r2124 r2127 45 45 TLSContext &rTLSContext, 46 46 const std::string &rHostname, 47 int Port, 47 48 int32_t AccountNumber, 48 49 bool ExtendedLogging, … … 53 54 mrTLSContext(rTLSContext), 54 55 mHostname(rHostname), 56 mPort(Port), 55 57 mAccountNumber(AccountNumber), 56 58 mpSocket(0), … … 130 132 131 133 // Connect! 132 mpSocket->Open(mrTLSContext, Socket::TypeINET, mHostname.c_str(), BOX_PORT_BBSTORED); 134 mpSocket->Open(mrTLSContext, Socket::TypeINET, 135 mHostname.c_str(), mPort); 133 136 134 137 // And create a procotol object … … 147 150 if (!mpExtendedLogFileHandle) 148 151 { 149 BOX_ ERROR("Failed to open extended log"150 " file: " << strerror(errno));152 BOX_LOG_SYS_ERROR("Failed to open extended " 153 "log file: " << mExtendedLogFile); 151 154 } 152 155 else -
box/trunk/bin/bbackupd/BackupClientContext.h
r2124 r2127 42 42 TLSContext &rTLSContext, 43 43 const std::string &rHostname, 44 int32_t Port, 44 45 int32_t AccountNumber, 45 46 bool ExtendedLogging, … … 202 203 TLSContext &mrTLSContext; 203 204 std::string mHostname; 205 int mPort; 204 206 int32_t mAccountNumber; 205 207 SocketStreamTLS *mpSocket; -
box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
r2124 r2127 1015 1015 if(mpPendingEntries != 0 && mpPendingEntries->size() == 0) 1016 1016 { 1017 TRACE1("Deleting mpPendingEntries from dir ID %lld\n", mObjectID); 1017 BOX_TRACE("Deleting mpPendingEntries from dir ID " << 1018 BOX_FORMAT_OBJECTID(mObjectID)); 1018 1019 delete mpPendingEntries; 1019 1020 mpPendingEntries = 0; … … 1250 1251 dirname.GetClearFilename()); 1251 1252 1252 TRACE1("Deleted directory record for"1253 " %s\n", name.c_str());1253 BOX_TRACE("Deleted directory record " 1254 "for " << name); 1254 1255 } 1255 1256 } -
box/trunk/bin/bbackupd/BackupDaemon.cpp
r2124 r2127 959 959 tlsContext, 960 960 conf.GetKeyValue("StoreHostname"), 961 conf.GetKeyValueInt("StorePort"), 961 962 conf.GetKeyValueInt("AccountNumber"), 962 963 conf.GetKeyValueBool("ExtendedLogging"), … … 1813 1814 #endif // HAVE_STRUCT_STATVFS_F_MNTONNAME 1814 1815 { 1815 BOX_ WARNING("Failed to stat location "1816 BOX_LOG_SYS_WARNING("Failed to stat location " 1816 1817 "path '" << apLoc->mPath << 1817 "' (" << strerror(errno) << 1818 "), skipping location '" << 1818 "', skipping location '" << 1819 1819 apLoc->mName << "'"); 1820 1820 continue; … … 2190 2190 if(::rename(newmap.c_str(), target.c_str()) != 0) 2191 2191 { 2192 BOX_ERROR("failed to rename ID map: " << newmap 2193 << " to " << target << ": " 2194 << strerror(errno)); 2192 BOX_LOG_SYS_ERROR("Failed to rename ID map: " << 2193 newmap << " to " << target); 2195 2194 THROW_EXCEPTION(CommonException, OSFileError) 2196 2195 } … … 3056 3055 if(!FileExists(storeObjectInfoFile.c_str())) 3057 3056 { 3058 // File doesn't exist -- so can't be deleted. But something isn't quite right, so log a message 3059 BOX_WARNING("Store object info file did not exist when it " 3060 "was supposed to. (" << storeObjectInfoFile << ")"); 3057 // File doesn't exist -- so can't be deleted. But something 3058 // isn't quite right, so log a message 3059 BOX_WARNING("StoreObjectInfoFile did not exist when it " 3060 "was supposed to: " << storeObjectInfoFile); 3061 3061 3062 3062 // Return true to stop things going around in a loop … … 3067 3067 if(::unlink(storeObjectInfoFile.c_str()) != 0) 3068 3068 { 3069 BOX_ ERROR("Failed to delete the old store object info file:"3070 << storeObjectInfoFile << ": "<< strerror(errno));3069 BOX_LOG_SYS_ERROR("Failed to delete the old " 3070 "StoreObjectInfoFile: " << storeObjectInfoFile); 3071 3071 return false; 3072 3072 } -
box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp
r2124 r2127 208 208 if (emu_stat(pConfigFileName, &st) != 0) 209 209 { 210 BOX_ ERROR("Failed to open configuration file '" <<211 pConfigFileName << "': " << strerror(errno));210 BOX_LOG_SYS_ERROR("Failed to open configuration file " 211 "'" << pConfigFileName << "'"); 212 212 return 1; 213 213 } … … 222 222 } 223 223 224 SC_HANDLE scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE);224 SC_HANDLE scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); 225 225 226 226 if (!scm) -
box/trunk/bin/bbackupd/bbackupd-config.in
r2124 r2127 27 27 account-num (hexdecimal) and server-hostname 28 28 are supplied by the server administrator 29 working-dir is usually @localstatedir_expanded@ 29 working-dir is usually @localstatedir_expanded@/bbackupd 30 30 backup directories is list of directories to back up 31 31 -
box/trunk/bin/bbackupquery/BackupQueries.cpp
r2124 r2127 28 28 #include <set> 29 29 #include <limits> 30 #include <iostream> 31 #include <ostream> 30 32 31 33 #include "BackupQueries.h" … … 811 813 else 812 814 { 813 BOX_ ERROR("Error changing to directory '" <<814 args[0] << ": " << strerror(errno));815 BOX_LOG_SYS_ERROR("Failed to change to directory " 816 "'" << args[0] << "'"); 815 817 } 816 818 … … 823 825 if(::getcwd(wd, PATH_MAX) == 0) 824 826 { 825 BOX_ERROR("Error getting current directory: " << 826 strerror(errno)); 827 BOX_LOG_SYS_ERROR("Error getting current directory"); 827 828 SetReturnCode(COMMAND_RETURN_ERROR); 828 829 return; … … 1400 1401 else 1401 1402 { 1402 BOX_WARNING("Failed to access local directory '" << 1403 localDirDisplay << ": " << strerror(errno) << 1404 "'."); 1403 BOX_LOG_SYS_WARNING("Failed to access local directory " 1404 "'" << localDirDisplay << "'"); 1405 1405 rParams.mUncheckedFiles ++; 1406 1406 } … … 1450 1450 if(dirhandle == 0) 1451 1451 { 1452 BOX_ WARNING("Failed to open local directory '" <<1453 localDirDisplay << "' : " << strerror(errno));1452 BOX_LOG_SYS_WARNING("Failed to open local directory '" << 1453 localDirDisplay << "'"); 1454 1454 rParams.mUncheckedFiles ++; 1455 1455 return; … … 1519 1519 if(::closedir(dirhandle) != 0) 1520 1520 { 1521 BOX_ ERROR("Failed to close local directory '" <<1522 localDirDisplay << "': " << strerror(errno));1521 BOX_LOG_SYS_ERROR("Failed to close local directory " 1522 "'" << localDirDisplay << "'"); 1523 1523 } 1524 1524 dirhandle = 0; … … 2159 2159 void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize) 2160 2160 { 2161 // Calculate size in Mb 2162 double mb = (((double)Size) * ((double)BlockSize)) / ((double)(1024*1024)); 2163 int64_t percent = (Size * 100) / HardLimit; 2164 2165 // Bar graph 2166 char bar[41]; 2167 unsigned int b = (int)((Size * (sizeof(bar)-1)) / HardLimit); 2168 if(b > sizeof(bar)-1) {b = sizeof(bar)-1;} 2169 for(unsigned int l = 0; l < b; l++) 2170 { 2171 bar[l] = '*'; 2172 } 2173 bar[b] = '\0'; 2174 2175 // Print the entryj 2176 ::printf("%14s %10.1fMb %3d%% %s\n", Name, mb, (int32_t)percent, bar); 2161 std::cout << FormatUsageLineStart(Name) << 2162 FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize) << 2163 std::endl; 2177 2164 } 2178 2165 -
box/trunk/bin/bbackupquery/bbackupquery.cpp
r2124 r2127 175 175 if(logFile == 0) 176 176 { 177 BOX_ ERROR("Failed to open log file '" <<178 optarg << "': " << strerror(errno));177 BOX_LOG_SYS_ERROR("Failed to open log file " 178 "'" << optarg << "'"); 179 179 } 180 180 break; … … 261 261 if(!quiet) BOX_INFO("Connecting to store..."); 262 262 SocketStreamTLS socket; 263 socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED); 263 socket.Open(tlsContext, Socket::TypeINET, 264 conf.GetKeyValue("StoreHostname").c_str(), 265 conf.GetKeyValueInt("StorePort")); 264 266 265 267 // 3. Make a protocol, and handshake -
box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
r2126 r2127 14 14 #include <sys/types.h> 15 15 #include <limits.h> 16 17 #include <algorithm> 18 #include <iostream> 19 #include <ostream> 16 20 #include <vector> 17 #include <algorithm>18 21 19 22 #include "BoxPortsAndFiles.h" … … 63 66 } 64 67 65 std::string BlockSizeToString(int64_t Blocks, int DiscSet) 66 { 67 // Work out size in Mb. 68 double mb = (Blocks * BlockSizeOfDiscSet(DiscSet)) / (1024.0*1024.0); 69 70 // Format string 71 std::ostringstream buf; 72 buf << Blocks << " blocks " << std::fixed << std::setprecision(2) << 73 std::showpoint << "(" << mb << " MB)"; 74 return buf.str(); 68 std::string BlockSizeToString(int64_t Blocks, int64_t MaxBlocks, int DiscSet) 69 { 70 return FormatUsageBar(Blocks, Blocks * BlockSizeOfDiscSet(DiscSet), 71 MaxBlocks * BlockSizeOfDiscSet(DiscSet)); 75 72 } 76 73 … … 224 221 225 222 // Then print out lots of info 226 printf(" Account ID: %08x\n", ID); 227 printf(" Last object ID: %lld\n", info->GetLastObjectIDUsed()); 228 printf(" Blocks used: %s\n", BlockSizeToString(info->GetBlocksUsed(), discSet).c_str()); 229 printf(" Blocks used by old files: %s\n", BlockSizeToString(info->GetBlocksInOldFiles(), discSet).c_str()); 230 printf("Blocks used by deleted files: %s\n", BlockSizeToString(info->GetBlocksInDeletedFiles(), discSet).c_str()); 231 printf(" Blocks used by directories: %s\n", BlockSizeToString(info->GetBlocksInDirectories(), discSet).c_str()); 232 printf(" Block soft limit: %s\n", BlockSizeToString(info->GetBlocksSoftLimit(), discSet).c_str()); 233 printf(" Block hard limit: %s\n", BlockSizeToString(info->GetBlocksHardLimit(), discSet).c_str()); 234 printf(" Client store marker: %lld\n", info->GetClientStoreMarker()); 223 std::cout << FormatUsageLineStart("Account ID") << 224 BOX_FORMAT_ACCOUNT(ID) << std::endl; 225 std::cout << FormatUsageLineStart("Last object ID") << 226 BOX_FORMAT_OBJECTID(info->GetLastObjectIDUsed()) << std::endl; 227 std::cout << FormatUsageLineStart("Used") << 228 BlockSizeToString(info->GetBlocksUsed(), 229 info->GetBlocksHardLimit(), discSet) << std::endl; 230 std::cout << FormatUsageLineStart("Old files") << 231 BlockSizeToString(info->GetBlocksInOldFiles(), 232 info->GetBlocksHardLimit(), discSet) << std::endl; 233 std::cout << FormatUsageLineStart("Deleted files") << 234 BlockSizeToString(info->GetBlocksInDeletedFiles(), 235 info->GetBlocksHardLimit(), discSet) << std::endl; 236 std::cout << FormatUsageLineStart("Directories") << 237 BlockSizeToString(info->GetBlocksInDirectories(), 238 info->GetBlocksHardLimit(), discSet) << std::endl; 239 std::cout << FormatUsageLineStart("Soft limit") << 240 BlockSizeToString(info->GetBlocksSoftLimit(), 241 info->GetBlocksHardLimit(), discSet) << std::endl; 242 std::cout << FormatUsageLineStart("Hard limit") << 243 BlockSizeToString(info->GetBlocksHardLimit(), 244 info->GetBlocksHardLimit(), discSet) << std::endl; 245 std::cout << FormatUsageLineStart("Client store marker") << 246 info->GetLastObjectIDUsed() << std::endl; 235 247 236 248 return 0; -
box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
r2124 r2127 194 194 if(mInterProcessComms.GetLine(line, false /* no pre-processing */, MaximumWaitTime)) 195 195 { 196 TRACE1("Housekeeping received command '%s' over interprocess comms\n", line.c_str()); 196 BOX_TRACE("Housekeeping received command '" << line << 197 "' over interprocess comms"); 197 198 198 199 int account = 0; -
box/trunk/bin/bbstored/BackupContext.cpp
r2124 r2127 383 383 mSaveStoreInfoDelay = 0; 384 384 385 TRACE1("When allocating object ID, found that %lld is already in use\n", id); 385 BOX_WARNING("When allocating object ID, found that " << 386 BOX_FORMAT_OBJECTID(id) << " is already in use"); 386 387 } 387 388 -
box/trunk/bin/bbstored/bbstored-config.in
r2124 r2127 197 197 Server 198 198 { 199 PidFile = @localstatedir_expanded@/ bbstored.pid199 PidFile = @localstatedir_expanded@/run/bbstored.pid 200 200 User = $username 201 201 ListenAddresses = inet:$server -
box/trunk/configure.ac
r2124 r2127 6 6 AC_CONFIG_SRCDIR([lib/common/Box.h]) 7 7 AC_CONFIG_HEADERS([lib/common/BoxConfig.h]) 8 9 # override default sysconfdir, for backwards compatibility10 test "$sysconfdir" = NONE && sysconfdir=/etc11 test "$localstatedir" = NONE && localstatedir=/var/run12 8 13 9 touch install-sh … … 63 59 esac 64 60 65 AC_CHECK_HEADER([zlib.h],, [AC_MSG_ERROR([[cannot find zlib.h]])])66 61 AC_CHECK_LIB([z], [zlibVersion],, [AC_MSG_ERROR([[cannot find zlib]])]) 67 62 VL_LIB_READLINE([have_libreadline=yes], [have_libreadline=no]) … … 274 269 LIBS="-Wl,-Bstatic $LIBS -Wl,-Bdynamic" 275 270 fi 271 272 # override default sysconfdir, for backwards compatibility 273 test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc 274 test "$localstatedir" = '${prefix}/var' && localstatedir=/var 276 275 277 276 ## Kludge to allow makeparcels.pl to use bindir. This is not a good long term -
box/trunk/documentation/bbackupctl.xml
r2124 r2127 4 4 <refentrytitle>bbackupctl</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 24 24 <para><literal>bbackupctl</literal> lets the user control the bbackupd 25 25 daemon on a client machine. The main use is to force a sync with the store 26 server. This is especially important if bbackupd( 1) is configured to do26 server. This is especially important if bbackupd(8) is configured to do 27 27 snapshot backups. In that case <literal>bbackupctl</literal> is the only 28 28 way to effect a backup.</para> … … 32 32 connecting on this socket has the correct credentials to execute the 33 33 commands, leaving a rather sizeable security hole open. To avoid this, 34 unset the CommandSocket parameter in <literal>bbackupd.conf</literal>( 8).34 unset the CommandSocket parameter in <literal>bbackupd.conf</literal>(5). 35 35 That disables the command socket, so bbackupd is secure. This does, 36 36 however, render bbackupctl unusable.</para> … … 94 94 <title>See Also</title> 95 95 96 <para><literal>bbackupd.conf( 8)</literal></para>96 <para><literal>bbackupd.conf(5)</literal></para> 97 97 98 <para> bbackupd(1)</para>98 <para><literal>bbackupd(8)</literal></para> 99 99 </refsection> 100 100 -
box/trunk/documentation/bbackupquery.xml
r2124 r2127 4 4 <refentrytitle>bbackupquery</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 40 40 41 41 <para>Note that commands that contain spaces are enclosed in double 42 quotes. If the <literal>quit</literal> command is om mitted, after the42 quotes. If the <literal>quit</literal> command is omitted, after the 43 43 preceding commands are completed, <literal>bbackupquery</literal> will 44 44 enter interactive mode.</para> … … 329 329 <title>See Also</title> 330 330 331 <para>bbackupd.conf( 8)</para>331 <para>bbackupd.conf(5)</para> 332 332 </refsection> 333 333 … … 358 358 359 359 <listitem> 360 <para>The platform you are running on ( Hardware and OS), for both360 <para>The platform you are running on (hardware and OS), for both 361 361 client and server.</para> 362 362 </listitem> -
box/trunk/documentation/bbstoreaccounts.xml
r2124 r2127 4 4 <refentrytitle>bbstoreaccounts</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 29 29 server. </para> 30 30 31 <para><literal>bbstoreaccounts</literal> alwa s takes at least 231 <para><literal>bbstoreaccounts</literal> always takes at least 2 32 32 parameters: the command name and the account ID. Some commands require 33 33 additional parameters, and some commands have optional parameters.</para> … … 161 161 <listitem> 162 162 <para>Blocks used by deleted files: The number of blocks used by 163 files that have been deleted on the client. Thi s data is at163 files that have been deleted on the client. This data is at 164 164 risk for being removed during housekeeping.</para> 165 165 </listitem> … … 268 268 269 269 <listitem> 270 <para>The platform you are running on ( Hardware and OS), for both270 <para>The platform you are running on (hardware and OS), for both 271 271 client and server.</para> 272 272 </listitem> -
box/trunk/documentation/bbstored-certs.xml
r2124 r2127 4 4 <refentrytitle>bbstored-certs</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 52 52 <para><literal>sign <clientcsrfile></literal>: Sign a client 53 53 certificate. The <literal>clientcsrfile</literal> is generated 54 during client setup. See <literal>bbackupd-config( 1)</literal>. Send54 during client setup. See <literal>bbackupd-config(8)</literal>. Send 55 55 the signed certificate back to the client, and install according to 56 56 the instructions given by <literal>bbackupd-config</literal>.</para> … … 73 73 <title>See Also</title> 74 74 75 <para><literal>bbstored-config( 1)</literal></para>75 <para><literal>bbstored-config(8)</literal></para> 76 76 77 77 <para><literal>bbstored.conf(5)</literal></para> 78 78 79 <para><literal>bbstoreaccounts( 1)</literal></para>79 <para><literal>bbstoreaccounts(8)</literal></para> 80 80 </refsection> 81 81 … … 103 103 104 104 <listitem> 105 <para>The platform you are running on ( Hardware and OS), for both105 <para>The platform you are running on (hardware and OS), for both 106 106 client and server.</para> 107 107 </listitem> -
box/trunk/documentation/bbstored-config.xml
r2124 r2127 4 4 <refentrytitle>bbstored-config</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 87 87 <title>See Also</title> 88 88 89 <para><literal>raidfile-config( 1)</literal></para>89 <para><literal>raidfile-config(8)</literal></para> 90 90 91 91 <para><literal>bbstored.conf(5)</literal></para> … … 118 118 119 119 <listitem> 120 <para>The platform you are running on ( Hardware and OS), for both120 <para>The platform you are running on (hardware and OS), for both 121 121 client and server.</para> 122 122 </listitem> -
box/trunk/documentation/raidfile-config.xml
r2124 r2127 4 4 <refentrytitle>raidfile-config</refentrytitle> 5 5 6 <manvolnum> 1</manvolnum>6 <manvolnum>8</manvolnum> 7 7 </refmeta> 8 8 … … 46 46 <listitem> 47 47 <para><literal>blocksize</literal>: The block size used for file 48 storage in the system, in bytes. Using a mult ple of the file system48 storage in the system, in bytes. Using a multiple of the file system 49 49 block size is a good strategy. Depending on the size of the files 50 50 you will be backing up, this multiple varies. Of course it also … … 91 91 <title>See Also</title> 92 92 93 <para><literal>bbstored-config( 1)</literal></para>93 <para><literal>bbstored-config(8)</literal></para> 94 94 95 95 <para><literal>bbstored.conf(5)</literal></para> … … 121 121 122 122 <listitem> 123 <para>The platform you are running on ( Hardware and OS), for both123 <para>The platform you are running on (hardware and OS), for both 124 124 client and server.</para> 125 125 </listitem> -
box/trunk/lib/backupclient/BackupClientRestore.cpp
r2124 r2127 268 268 if(::unlink(rLocalDirectoryName.c_str()) != 0) 269 269 { 270 BOX_ ERROR("Failed to delete file " <<271 rLocalDirectoryName << ": " <<272 strerror(errno));270 BOX_LOG_SYS_ERROR("Failed to delete " 271 "file '" << 272 rLocalDirectoryName << "'"); 273 273 return Restore_UnknownError; 274 274 } 275 275 BOX_TRACE("In restore, directory name " 276 "collision with file " <<277 rLocalDirectoryName );276 "collision with file '" << 277 rLocalDirectoryName << "'"); 278 278 } 279 279 break; … … 379 379 ::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0) 380 380 { 381 BOX_ERROR("Failed to create directory '" << 382 rLocalDirectoryName << "': " << 383 strerror(errno)); 381 BOX_LOG_SYS_ERROR("Failed to create directory '" << 382 rLocalDirectoryName << "'"); 384 383 return Restore_UnknownError; 385 384 } … … 452 451 // Local name 453 452 BackupStoreFilenameClear nm(en->GetName()); 454 std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename()); 453 std::string localFilename(rLocalDirectoryName + 454 DIRECTORY_SEPARATOR_ASCHAR + 455 nm.GetClearFilename()); 455 456 456 457 // Unlink anything which already exists: … … 460 461 ::unlink(localFilename.c_str()) != 0) 461 462 { 462 BOX_ ERROR("Failed to delete file '" <<463 localFilename << "': " <<464 strerror(errno));463 BOX_LOG_SYS_ERROR("Failed to delete " 464 "file '" << localFilename << 465 "'"); 465 466 return Restore_UnknownError; 466 467 } 467 468 468 469 // Request it from the store 469 rConnection.QueryGetFile(DirectoryID, en->GetObjectID()); 470 rConnection.QueryGetFile(DirectoryID, 471 en->GetObjectID()); 470 472 471 473 // Stream containing encoded file 472 std::auto_ptr<IOStream> objectStream(rConnection.ReceiveStream()); 473 474 // Decode the file -- need to do different things depending on whether 475 // the directory entry has additional attributes 474 std::auto_ptr<IOStream> objectStream( 475 rConnection.ReceiveStream()); 476 477 // Decode the file -- need to do different 478 // things depending on whether the directory 479 // entry has additional attributes 476 480 try 477 481 { -
box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp
r2124 r2127 18 18 static const ConfigurationVerifyKey backuplocationkeys[] = 19 19 { 20 {"ExcludeFile", 0, ConfigTest_MultiValueAllowed, 0},21 {"ExcludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},22 {"ExcludeDir", 0, ConfigTest_MultiValueAllowed, 0},23 {"ExcludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},24 {"AlwaysIncludeFile", 0, ConfigTest_MultiValueAllowed, 0},25 {"AlwaysIncludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},26 {"AlwaysIncludeDir", 0, ConfigTest_MultiValueAllowed, 0},27 {"AlwaysIncludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},28 {"Path", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}20 ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed), 21 ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed), 22 ConfigurationVerifyKey("ExcludeDir", ConfigTest_MultiValueAllowed), 23 ConfigurationVerifyKey("ExcludeDirsRegex", ConfigTest_MultiValueAllowed), 24 ConfigurationVerifyKey("AlwaysIncludeFile", ConfigTest_MultiValueAllowed), 25 ConfigurationVerifyKey("AlwaysIncludeFilesRegex", ConfigTest_MultiValueAllowed), 26 ConfigurationVerifyKey("AlwaysIncludeDir", ConfigTest_MultiValueAllowed), 27 ConfigurationVerifyKey("AlwaysIncludeDirsRegex", ConfigTest_MultiValueAllowed), 28 ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry) 29 29 }; 30 30 … … 65 65 static const ConfigurationVerifyKey verifyrootkeys[] = 66 66 { 67 {"AccountNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 67 ConfigurationVerifyKey("AccountNumber", 68 ConfigTest_Exists | ConfigTest_IsInt), 69 ConfigurationVerifyKey("UpdateStoreInterval", 70 ConfigTest_Exists | ConfigTest_IsInt), 71 ConfigurationVerifyKey("MinimumFileAge", 72 ConfigTest_Exists | ConfigTest_IsInt), 73 ConfigurationVerifyKey("MaxUploadWait", 74 ConfigTest_Exists | ConfigTest_IsInt), 75 ConfigurationVerifyKey("MaxFileTimeInFuture", ConfigTest_IsInt, 172800), 76 // file is uploaded if the file is this much in the future 77 // (2 days default) 78 ConfigurationVerifyKey("AutomaticBackup", ConfigTest_IsBool, true), 79 80 ConfigurationVerifyKey("SyncAllowScript", 0), 81 // script that returns "now" if backup is allowed now, or a number 82 // of seconds to wait before trying again if not 68 83 69 {"UpdateStoreInterval", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 70 {"MinimumFileAge", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 71 {"MaxUploadWait", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 72 {"MaxFileTimeInFuture", "172800", ConfigTest_IsInt, 0}, // file is uploaded if the file is this much in the future (2 days default) 84 ConfigurationVerifyKey("MaximumDiffingTime", ConfigTest_IsInt), 85 ConfigurationVerifyKey("DeleteRedundantLocationsAfter", 86 ConfigTest_IsInt, 172800), 73 87 74 {"AutomaticBackup", "yes", ConfigTest_IsBool, 0}, 88 ConfigurationVerifyKey("FileTrackingSizeThreshold", 89 ConfigTest_Exists | ConfigTest_IsInt), 90 ConfigurationVerifyKey("DiffingUploadSizeThreshold", 91 ConfigTest_Exists | ConfigTest_IsInt), 92 ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists), 93 ConfigurationVerifyKey("StorePort", ConfigTest_IsInt, 94 BOX_PORT_BBSTORED), 95 ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false), 96 // extended log to syslog 97 ConfigurationVerifyKey("ExtendedLogFile", 0), 98 // extended log to a file 99 ConfigurationVerifyKey("LogAllFileAccess", ConfigTest_IsBool, false), 100 ConfigurationVerifyKey("CommandSocket", 0), 101 // not compulsory to have this 102 ConfigurationVerifyKey("KeepAliveTime", ConfigTest_IsInt), 103 ConfigurationVerifyKey("StoreObjectInfoFile", 0), 104 // optional 105 106 ConfigurationVerifyKey("NotifyScript", 0), 107 // optional script to run when backup needs attention, eg store full 75 108 76 {"SyncAllowScript", 0, 0, 0}, // optional script to run to see if the sync should be started now 77 // return "now" if it's allowed, or a number of seconds if it's not 78 79 {"MaximumDiffingTime", 0, ConfigTest_IsInt, 0}, 80 {"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0}, 81 82 {"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 83 {"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 84 {"StoreHostname", 0, ConfigTest_Exists, 0}, 85 {"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // extended log to syslog 86 {"ExtendedLogFile", NULL, 0, 0}, // extended log to a file 87 {"LogAllFileAccess", "no", ConfigTest_IsBool, 0}, 88 89 {"CommandSocket", 0, 0, 0}, // not compulsory to have this 90 {"KeepAliveTime", 0, ConfigTest_IsInt, 0}, // optional 91 {"StoreObjectInfoFile", 0, 0, 0}, // optional 92 93 {"NotifyScript", 0, 0, 0}, // optional script to run when backup needs attention, eg store full 94 95 {"CertificateFile", 0, ConfigTest_Exists, 0}, 96 {"PrivateKeyFile", 0, ConfigTest_Exists, 0}, 97 {"TrustedCAsFile", 0, ConfigTest_Exists, 0}, 98 {"KeysFile", 0, ConfigTest_Exists, 0}, 99 {"DataDirectory", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 109 ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists), 110 ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists), 111 ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists), 112 ConfigurationVerifyKey("KeysFile", ConfigTest_Exists), 113 ConfigurationVerifyKey("DataDirectory", 114 ConfigTest_Exists | ConfigTest_LastEntry), 100 115 }; 101 116 -
box/trunk/lib/backupclient/BackupStoreFileDiff.cpp
r2124 r2127 150 150 bool canDiffFromThis = false; 151 151 LoadIndex(rDiffFromBlockIndex, DiffFromObjectID, &pindex, blocksInIndex, Timeout, canDiffFromThis); 152 // TRACE1("Diff: Blocks in index: %lld\n",blocksInIndex);152 // BOX_TRACE("Diff: Blocks in index: " << blocksInIndex); 153 153 154 154 if(!canDiffFromThis) … … 440 440 for(int t = 0; t < BACKUP_FILE_DIFF_MAX_BLOCK_SIZES; ++t) 441 441 { 442 TRACE3("Diff block size %d: %d (count = %lld)\n", t, Sizes[t], sizeCounts[t]); 442 BOX_TRACE("Diff block size " << t << ": " << 443 Sizes[t] << " (count = " << 444 sizeCounts[t] << ")"); 443 445 } 444 446 } … … 775 777 if(pHashTable[hash] != 0) 776 778 { 777 // TRACE1("Another hash entry for %d found\n", hash);779 //BOX_TRACE("Another hash entry for " << hash << " found"); 778 780 // Yes -- need to set the pointer in this entry to the current entry to build the linked list 779 781 pIndex[b].mpNextInHashList = pHashTable[hash]; … … 841 843 // Then go through the entries in the hash list, comparing with the strong digest calculated 842 844 scan = pFirstInHashList; 843 // TRACE0("second stage match\n");845 //BOX_TRACE("second stage match"); 844 846 while(scan != 0) 845 847 { 846 //TRACE3("scan size %d, block size %d, hash %d\n", scan->mSize, BlockSize, Hash); 848 //BOX_TRACE("scan size " << scan->mSize << 849 // ", block size " << BlockSize << 850 // ", hash " << Hash); 847 851 ASSERT(scan->mSize == BlockSize); 848 852 ASSERT(RollingChecksum::ExtractHashingComponent(scan->mWeakChecksum) == DEBUG_Hash); … … 851 855 if(strong.DigestMatches(scan->mStrongChecksum)) 852 856 { 853 // TRACE0("Match!\n");857 //BOX_TRACE("Match!\n"); 854 858 // Found! Add to list of found blocks... 855 859 int64_t fileOffset = (FileBlockNumber * BlockSize) + Offset; … … 913 917 if(BackupStoreFile::TraceDetailsOfDiffProcess) 914 918 { 915 TRACE1("Diff: Default recipe generated, %lld bytes of file\n", SizeOfInputFile); 919 BOX_TRACE("Diff: Default recipe generated, " << 920 SizeOfInputFile << " bytes of file"); 916 921 } 917 922 #endif … … 1006 1011 // dump out the recipe 1007 1012 #ifndef NDEBUG 1008 TRACE2("Diff: %lld new bytes found, %lld old blocks used\n", debug_NewBytesFound, debug_OldBlocksUsed); 1013 BOX_TRACE("Diff: " << 1014 debug_NewBytesFound << " new bytes found, " << 1015 debug_OldBlocksUsed << " old blocks used"); 1009 1016 if(BackupStoreFile::TraceDetailsOfDiffProcess) 1010 1017 { 1011 TRACE1("Diff: Recipe generated (size %d)\n======== ========= ========\nSpace b4 FirstBlk NumBlks\n", rRecipe.size()); 1018 BOX_TRACE("Diff: Recipe generated (size " << rRecipe.size()); 1019 BOX_TRACE("======== ========= ========"); 1020 BOX_TRACE("Space b4 FirstBlk NumBlks"); 1012 1021 { 1013 1022 for(unsigned int e = 0; e < rRecipe.size(); ++e) … … 1019 1028 sprintf(b, "%8lld", (int64_t)(rRecipe[e].mpStartBlock - pIndex)); 1020 1029 #endif 1021 TRACE3("%8lld %s %8lld\n", rRecipe[e].mSpaceBefore, (rRecipe[e].mpStartBlock == 0)?" -":b, (int64_t)rRecipe[e].mBlocks); 1022 } 1023 } 1024 TRACE0("======== ========= ========\n"); 1030 BOX_TRACE(std::setw(8) << 1031 rRecipe[e].mSpaceBefore << 1032 " " << 1033 ((rRecipe[e].mpStartBlock == 0)?" -":b) << 1034 " " << std::setw(8) << 1035 rRecipe[e].mBlocks); 1036 } 1037 } 1038 BOX_TRACE("======== ========= ========"); 1025 1039 } 1026 1040 #endif -
box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp
r2124 r2127 168 168 { 169 169 case Encoding_Clear: 170 TRACE0("**** BackupStoreFilename encoded with Clear encoding ****\n"); 170 BOX_TRACE("**** BackupStoreFilename encoded with " 171 "Clear encoding ****"); 171 172 mClearFilename.assign(c_str() + 2, size - 2); 172 173 break; … … 194 195 { 195 196 #ifndef WIN32 196 TRACE1("Allocating filename encoding/decoding buffer with size %d\n", BufSize); 197 BOX_TRACE("Allocating filename encoding/decoding buffer " 198 "with size " << BufSize); 197 199 #endif 198 200 spEncDecBuffer = new MemoryBlockGuard<uint8_t *>(BufSize); -
box/trunk/lib/backupclient/BackupStoreObjectDump.cpp
r2124 r2127 48 48 if(ToTrace) 49 49 { 50 TRACE1("%s",text);50 BOX_TRACE(text); 51 51 } 52 52 } … … 212 212 { 213 213 nnew++; 214 TRACE2("%8lld this s=%8lld\n", b, s); 214 BOX_TRACE(std::setw(8) << b << " this s=" << 215 std::setw(8) << s); 215 216 } 216 217 else 217 218 { 218 219 nold++; 219 TRACE2("%8lld other i=%8lld\n", b, 0 - s); 220 } 221 } 222 TRACE0("======== ===== ==========\n"); 220 BOX_TRACE(std::setw(8) << b << " other i=" << 221 std::setw(8) << 0 - s); 222 } 223 } 224 BOX_TRACE("======== ===== =========="); 223 225 } 224 226 -
box/trunk/lib/backupstore/BackupStoreCheck.cpp
r2124 r2127 269 269 270 270 maxDir = CheckObjectsScanDir(0, 1, mStoreRoot); 271 TRACE1("Max dir starting ID is %llx\n", maxDir); 271 BOX_TRACE("Max dir starting ID is " << 272 BOX_FORMAT_OBJECTID(maxDir)); 272 273 } 273 274 -
box/trunk/lib/backupstore/BackupStoreCheck2.cpp
r2124 r2127 595 595 } 596 596 597 #define FMT_OID(x) BOX_FORMAT_OBJECTID(x) 598 #define FMT_i BOX_FORMAT_OBJECTID((*i)->GetObjectID()) 597 599 598 600 // -------------------------------------------------------------------------- … … 621 623 { 622 624 // Depends on something, but it isn't there. 623 TRACE2("Entry id %llx removed because depends on newer version %llx which doesn't exist\n", (*i)->GetObjectID(), dependsNewer); 625 BOX_TRACE("Entry id " << FMT_i << 626 " removed because depends " 627 "on newer version " << 628 FMT_OID(dependsNewer) << 629 " which doesn't exist"); 624 630 625 631 // Remove … … 639 645 { 640 646 // Wrong entry 641 TRACE3("Entry id %llx, correcting DependsOlder to %llx, was %llx\n", dependsNewer, (*i)->GetObjectID(), newerEn->GetDependsOlder()); 647 BOX_TRACE("Entry id " << 648 FMT_OID(dependsNewer) << 649 ", correcting DependsOlder to " << 650 FMT_i << 651 ", was " << 652 FMT_OID(newerEn->GetDependsOlder())); 642 653 newerEn->SetDependsOlder((*i)->GetObjectID()); 643 654 // Mark as changed … … 658 669 { 659 670 // Has an older version marked, but this doesn't exist. Remove this mark 660 TRACE2("Entry id %llx was marked that %llx depended on it, which doesn't exist, dependency info cleared\n", (*i)->GetObjectID(), dependsOlder); 671 BOX_TRACE("Entry id " << FMT_i << 672 " was marked as depended on by " << 673 FMT_OID(dependsOlder) << ", " 674 "which doesn't exist, dependency " 675 "info cleared"); 661 676 662 677 (*i)->SetDependsOlder(0); … … 694 709 if((*i) == 0) 695 710 { 696 TRACE0("Remove because null pointer found\n");711 BOX_TRACE("Remove because null pointer found"); 697 712 removeEntry = true; 698 713 } … … 705 720 { 706 721 // Bad! Unset the file flag 707 TRACE1("Entry %llx: File flag set when dir flag set\n", (*i)->GetObjectID()); 722 BOX_TRACE("Entry " << FMT_i << 723 ": File flag and dir flag both set"); 708 724 (*i)->RemoveFlags(Entry::Flags_File); 709 725 changed = true; … … 714 730 { 715 731 // ID already seen, or type doesn't match 716 TRACE1("Entry %llx: Remove because ID already seen\n", (*i)->GetObjectID()); 732 BOX_TRACE("Entry " << FMT_i << 733 ": Remove because ID already seen"); 717 734 removeEntry = true; 718 735 } … … 731 748 { 732 749 // Not set, set it 733 TRACE1("Entry %llx: Set old flag\n", (*i)->GetObjectID()); 750 BOX_TRACE("Entry " << FMT_i << 751 ": Set old flag"); 734 752 (*i)->AddFlags(Entry::Flags_OldVersion); 735 753 changed = true; … … 742 760 { 743 761 // Set, unset it 744 TRACE1("Entry %llx: Old flag unset\n", (*i)->GetObjectID()); 762 BOX_TRACE("Entry " << FMT_i << 763 ": Old flag unset"); 745 764 (*i)->RemoveFlags(Entry::Flags_OldVersion); 746 765 changed = true; -
box/trunk/lib/backupstore/BackupStoreCheckData.cpp
r2124 r2127 190 190 IDBlock *pblock = i->second; 191 191 int32_t bentries = (pblock == mpInfoLastBlock)?mInfoLastBlockEntries:BACKUPSTORECHECK_BLOCK_SIZE; 192 TRACE2("BLOCK @ 0x%08x, %d entries\n", pblock, bentries); 192 BOX_TRACE("BLOCK @ " << BOX_FORMAT_HEX32(pblock) << 193 ", " << bentries << " entries"); 193 194 194 195 for(int e = 0; e < bentries; ++e) 195 196 { 196 197 uint8_t flags = GetFlags(pblock, e); 197 TRACE4("id %llx, c %llx, %s, %s\n", 198 pblock->mID[e], pblock->mContainer[e], 199 (flags & Flags_IsDir)?"dir":"file", 200 (flags & Flags_IsContained)?"contained":"unattached"); 198 BOX_TRACE(std::hex << 199 "id " << pblock->mID[e] << 200 ", c " << pblock->mContainer[e] << 201 ", " << ((flags & Flags_IsDir)?"dir":"file") << 202 ", " << ((flags & Flags_IsContained) ? 203 "contained":"unattached")); 201 204 } 202 205 } -
box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp
r2124 r2127 17 17 static const ConfigurationVerifyKey verifyserverkeys[] = 18 18 { 19 SERVERTLS_VERIFY_SERVER_KEYS(0) // no default listen addresses 19 SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) 20 // no default listen addresses 20 21 }; 21 22 … … 33 34 static const ConfigurationVerifyKey verifyrootkeys[] = 34 35 { 35 {"AccountDatabase", 0, ConfigTest_Exists, 0}, 36 {"TimeBetweenHousekeeping", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 37 {"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // make value "yes" to enable in config file 36 ConfigurationVerifyKey("AccountDatabase", ConfigTest_Exists), 37 ConfigurationVerifyKey("TimeBetweenHousekeeping", 38 ConfigTest_Exists | ConfigTest_IsInt), 39 ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false), 40 // make value "yes" to enable in config file 38 41 39 42 #ifdef WIN32 40 {"RaidFileConf", "", ConfigTest_LastEntry, 0}43 ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry) 41 44 #else 42 {"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0} 45 ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry, 46 BOX_FILE_RAIDFILE_DEFAULT_CONFIG) 43 47 #endif 44 45 48 }; 46 49 -
box/trunk/lib/common/Box.h
r2124 r2127 53 53 int BoxDebug_printf(const char *format, ...); 54 54 int BoxDebugTrace(const char *format, ...); 55 #define TRACE0(msg) {BoxDebugTrace("%s", msg);}56 #define TRACE1(msg, a0) {BoxDebugTrace(msg, a0);}57 #define TRACE2(msg, a0, a1) {BoxDebugTrace(msg, a0, a1);}58 #define TRACE3(msg, a0, a1, a2) {BoxDebugTrace(msg, a0, a1, a2);}59 #define TRACE4(msg, a0, a1, a2, a3) {BoxDebugTrace(msg, a0, a1, a2, a3);}60 #define TRACE5(msg, a0, a1, a2, a3, a4) {BoxDebugTrace(msg, a0, a1, a2, a3, a4);}61 #define TRACE6(msg, a0, a1, a2, a3, a4, a5) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5);}62 #define TRACE7(msg, a0, a1, a2, a3, a4, a5, a6) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5, a6);}63 #define TRACE8(msg, a0, a1, a2, a3, a4, a5, a6, a7) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5, a6, a7);}64 55 65 56 #ifndef PLATFORM_DISABLE_MEM_LEAK_TESTING … … 77 68 #define TRACE_TO_STDOUT(x) {} 78 69 79 #define TRACE0(msg)80 #define TRACE1(msg, a0)81 #define TRACE2(msg, a0, a1)82 #define TRACE3(msg, a0, a1, a2)83 #define TRACE4(msg, a0, a1, a2, a3)84 #define TRACE5(msg, a0, a1, a2, a3, a4)85 #define TRACE6(msg, a0, a1, a2, a3, a4, a5)86 #define TRACE7(msg, a0, a1, a2, a3, a4, a5, a6)87 #define TRACE8(msg, a0, a1, a2, a3, a4, a5, a6, a7)88 89 70 // Box Backup builds release get extra information for exception logging 90 71 #define EXCEPTION_CODENAMES_EXTENDED -
box/trunk/lib/common/BoxTime.cpp
r2124 r2127 40 40 if (gettimeofday(&tv, NULL) != 0) 41 41 { 42 BOX_ ERROR("Failed to gettimeofday(), dropping"43 " precision: " << strerror(errno));42 BOX_LOG_SYS_ERROR("Failed to gettimeofday(), " 43 "dropping precision"); 44 44 } 45 45 else -
box/trunk/lib/common/Configuration.cpp
r2124 r2127 12 12 #include <stdlib.h> 13 13 #include <limits.h> 14 15 #include <sstream> 14 16 15 17 #include "Configuration.h" … … 30 32 static const bool sValueBooleanValue[] = {true, true, false, false}; 31 33 32 34 ConfigurationVerifyKey::ConfigurationVerifyKey 35 ( 36 std::string name, 37 int flags, 38 void *testFunction 39 ) 40 : mName(name), 41 mHasDefaultValue(false), 42 mFlags(flags), 43 mTestFunction(testFunction) 44 { } 45 46 // to allow passing NULL for default ListenAddresses 47 48 ConfigurationVerifyKey::ConfigurationVerifyKey 49 ( 50 std::string name, 51 int flags, 52 NoDefaultValue_t t, 53 void *testFunction 54 ) 55 : mName(name), 56 mHasDefaultValue(false), 57 mFlags(flags), 58 mTestFunction(testFunction) 59 { } 60 61 ConfigurationVerifyKey::ConfigurationVerifyKey 62 ( 63 std::string name, 64 int flags, 65 std::string defaultValue, 66 void *testFunction 67 ) 68 : mName(name), 69 mDefaultValue(defaultValue), 70 mHasDefaultValue(true), 71 mFlags(flags), 72 mTestFunction(testFunction) 73 { } 74 75 ConfigurationVerifyKey::ConfigurationVerifyKey 76 ( 77 std::string name, 78 int flags, 79 const char *defaultValue, 80 void *testFunction 81 ) 82 : mName(name), 83 mDefaultValue(defaultValue), 84 mHasDefaultValue(true), 85 mFlags(flags), 86 mTestFunction(testFunction) 87 { } 88 89 ConfigurationVerifyKey::ConfigurationVerifyKey 90 ( 91 std::string name, 92 int flags, 93 int defaultValue, 94 void *testFunction 95 ) 96 : mName(name), 97 mHasDefaultValue(true), 98 mFlags(flags), 99 mTestFunction(testFunction) 100 { 101 ASSERT(flags & ConfigTest_IsInt); 102 std::ostringstream val; 103 val << defaultValue; 104 mDefaultValue = val.str(); 105 } 106 107 ConfigurationVerifyKey::ConfigurationVerifyKey 108 ( 109 std::string name, 110 int flags, 111 bool defaultValue, 112 void *testFunction 113 ) 114 : mName(name), 115 mHasDefaultValue(true), 116 mFlags(flags), 117 mTestFunction(testFunction) 118 { 119 ASSERT(flags & ConfigTest_IsBool); 120 mDefaultValue = defaultValue ? "yes" : "no"; 121 } 122 123 ConfigurationVerifyKey::ConfigurationVerifyKey 124 ( 125 const ConfigurationVerifyKey& rToCopy 126 ) 127 : mName(rToCopy.mName), 128 mDefaultValue(rToCopy.mDefaultValue), 129 mHasDefaultValue(rToCopy.mHasDefaultValue), 130 mFlags(rToCopy.mFlags), 131 mTestFunction(rToCopy.mTestFunction) 132 { } 33 133 34 134 // -------------------------------------------------------------------------- … … 109 209 { 110 210 // An error occured, return now 111 //TRACE1("Error message from LoadInto: %s", rErrorMsg.c_str());112 TRACE0("Error at Configuration::LoadInfo\n");211 BOX_ERROR("Error in Configuration::LoadInfo: " << 212 rErrorMsg); 113 213 delete pconfig; 114 214 pconfig = 0; … … 121 221 if(!Verify(*pconfig, *pVerify, std::string(), rErrorMsg)) 122 222 { 123 //TRACE1("Error message from Verify: %s", rErrorMsg.c_str());124 TRACE0("Error at Configuration::Verify\n");223 BOX_ERROR("Error verifying configuration: " << 224 rErrorMsg); 125 225 delete pconfig; 126 226 pconfig = 0; … … 190 290 else 191 291 { 192 rErrorMsg += "Unexpected start block in " + rConfig.mName + "\n"; 292 rErrorMsg += "Unexpected start block in " + 293 rConfig.mName + "\n"; 193 294 } 194 295 } … … 291 392 // 292 393 // Function 293 // Name: Configuration::KeyExists(const char *)394 // Name: Configuration::KeyExists(const std::string&) 294 395 // Purpose: Checks to see if a key exists 295 396 // Created: 2003/07/23 296 397 // 297 398 // -------------------------------------------------------------------------- 298 bool Configuration::KeyExists(const char *pKeyName) const 299 { 300 if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 301 302 return mKeys.find(pKeyName) != mKeys.end(); 303 } 304 305 306 // -------------------------------------------------------------------------- 307 // 308 // Function 309 // Name: Configuration::GetKeyValue(const char *) 399 bool Configuration::KeyExists(const std::string& rKeyName) const 400 { 401 return mKeys.find(rKeyName) != mKeys.end(); 402 } 403 404 405 // -------------------------------------------------------------------------- 406 // 407 // Function 408 // Name: Configuration::GetKeyValue(const std::string&) 310 409 // Purpose: Returns the value of a configuration variable 311 410 // Created: 2003/07/23 312 411 // 313 412 // -------------------------------------------------------------------------- 314 const std::string &Configuration::GetKeyValue(const char *pKeyName) const 315 { 316 if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 317 318 std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 413 const std::string &Configuration::GetKeyValue(const std::string& rKeyName) const 414 { 415 std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 319 416 320 417 if(i == mKeys.end()) 321 418 { 322 BOX_ERROR("Missing configuration key: " << pKeyName);419 BOX_ERROR("Missing configuration key: " << rKeyName); 323 420 THROW_EXCEPTION(CommonException, ConfigNoKey) 324 421 } … … 333 430 // 334 431 // Function 335 // Name: Configuration::GetKeyValueInt(const char *)432 // Name: Configuration::GetKeyValueInt(const std::string& rKeyName) 336 433 // Purpose: Gets a key value as an integer 337 434 // Created: 2003/07/23 338 435 // 339 436 // -------------------------------------------------------------------------- 340 int Configuration::GetKeyValueInt(const char *pKeyName) const 341 { 342 if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 343 344 std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 437 int Configuration::GetKeyValueInt(const std::string& rKeyName) const 438 { 439 std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 345 440 346 441 if(i == mKeys.end()) … … 363 458 // 364 459 // Function 365 // Name: Configuration::GetKeyValueBool(const char *) const460 // Name: Configuration::GetKeyValueBool(const std::string&) 366 461 // Purpose: Gets a key value as a boolean 367 462 // Created: 17/2/04 368 463 // 369 464 // -------------------------------------------------------------------------- 370 bool Configuration::GetKeyValueBool(const char *pKeyName) const 371 { 372 if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 373 374 std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName)); 465 bool Configuration::GetKeyValueBool(const std::string& rKeyName) const 466 { 467 std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 375 468 376 469 if(i == mKeys.end()) … … 429 522 // 430 523 // Function 431 // Name: Configuration::SubConfigurationExists(const char *) 524 // Name: Configuration::SubConfigurationExists(const 525 // std::string&) 432 526 // Purpose: Checks to see if a sub configuration exists 433 527 // Created: 2003/07/23 434 528 // 435 529 // -------------------------------------------------------------------------- 436 bool Configuration::SubConfigurationExists(const char *pSubName) const 437 { 438 if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 439 530 bool Configuration::SubConfigurationExists(const std::string& rSubName) const 531 { 440 532 // Attempt to find it... 441 533 std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin()); … … 444 536 { 445 537 // This the one? 446 if(i->first == pSubName)538 if(i->first == rSubName) 447 539 { 448 540 // Yes. … … 459 551 // 460 552 // Function 461 // Name: Configuration::GetSubConfiguration(const char *) 553 // Name: Configuration::GetSubConfiguration(const 554 // std::string&) 462 555 // Purpose: Gets a sub configuration 463 556 // Created: 2003/07/23 464 557 // 465 558 // -------------------------------------------------------------------------- 466 const Configuration &Configuration::GetSubConfiguration(const char *pSubName) const 467 { 468 if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)} 469 559 const Configuration &Configuration::GetSubConfiguration(const std::string& 560 rSubName) const 561 { 470 562 // Attempt to find it... 471 563 std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin()); … … 474 566 { 475 567 // This the one? 476 if(i->first == pSubName)568 if(i->first == rSubName) 477 569 { 478 570 // Yes. … … 529 621 { 530 622 // Can the key be found? 531 ASSERT(pvkey->mpName); 532 if(rConfig.KeyExists(pvkey->mpName)) 623 if(rConfig.KeyExists(pvkey->Name())) 533 624 { 534 625 // Get value 535 const std::string &rval = rConfig.GetKeyValue(pvkey-> mpName);626 const std::string &rval = rConfig.GetKeyValue(pvkey->Name()); 536 627 const char *val = rval.c_str(); 537 628 538 629 // Check it's a number? 539 if((pvkey-> Tests& ConfigTest_IsInt) == ConfigTest_IsInt)630 if((pvkey->Flags() & ConfigTest_IsInt) == ConfigTest_IsInt) 540 631 { 541 632 // Test it... … … 546 637 // not a good value 547 638 ok = false; 548 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->mpName+ " (key) is not a valid integer.\n";639 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid integer.\n"; 549 640 } 550 641 } 551 642 552 643 // Check it's a bool? 553 if((pvkey-> Tests& ConfigTest_IsBool) == ConfigTest_IsBool)644 if((pvkey->Flags() & ConfigTest_IsBool) == ConfigTest_IsBool) 554 645 { 555 646 // See if it's one of the allowed strings. … … 569 660 { 570 661 ok = false; 571 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->mpName+ " (key) is not a valid boolean value.\n";662 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid boolean value.\n"; 572 663 } 573 664 } 574 665 575 666 // Check for multi valued statments where they're not allowed 576 if((pvkey-> Tests& ConfigTest_MultiValueAllowed) == 0)667 if((pvkey->Flags() & ConfigTest_MultiValueAllowed) == 0) 577 668 { 578 669 // Check to see if this key is a multi-value -- it shouldn't be … … 580 671 { 581 672 ok = false; 582 rErrorMsg += rLevel + rConfig.mName +"." + pvkey-> mpName+ " (key) multi value not allowed (duplicated key?).\n";673 rErrorMsg += rLevel + rConfig.mName +"." + pvkey->Name() + " (key) multi value not allowed (duplicated key?).\n"; 583 674 } 584 675 } … … 587 678 { 588 679 // Is it required to exist? 589 if((pvkey-> Tests& ConfigTest_Exists) == ConfigTest_Exists)680 if((pvkey->Flags() & ConfigTest_Exists) == ConfigTest_Exists) 590 681 { 591 682 // Should exist, but doesn't. 592 683 ok = false; 593 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->mpName + " (key) is missing.\n"; 594 } 595 else if(pvkey->mpDefaultValue) 596 { 597 rConfig.mKeys[std::string(pvkey->mpName)] = std::string(pvkey->mpDefaultValue); 684 rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is missing.\n"; 685 } 686 else if(pvkey->HasDefaultValue()) 687 { 688 rConfig.mKeys[pvkey->Name()] = 689 pvkey->DefaultValue(); 598 690 } 599 691 } 600 692 601 if((pvkey-> Tests& ConfigTest_LastEntry) == ConfigTest_LastEntry)693 if((pvkey->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry) 602 694 { 603 695 // No more! … … 619 711 while(scan) 620 712 { 621 if(scan-> mpName== i->first)713 if(scan->Name() == i->first) 622 714 { 623 715 found = true; … … 626 718 627 719 // Next? 628 if((scan-> Tests& ConfigTest_LastEntry) == ConfigTest_LastEntry)720 if((scan->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry) 629 721 { 630 722 break; … … 651 743 while(scan) 652 744 { 653 ASSERT(scan->mpName); 654 if(scan->mpName[0] == '*') 745 if(scan->mName.length() > 0 && scan->mName[0] == '*') 655 746 { 656 747 wildcardverify = scan; … … 660 751 if((scan->Tests & ConfigTest_Exists) == ConfigTest_Exists) 661 752 { 662 if(scan->mpName[0] == '*') 753 if(scan->mName.length() > 0 && 754 scan->mName[0] == '*') 663 755 { 664 756 // Check something exists … … 673 765 { 674 766 // Check real thing exists 675 if(!rConfig.SubConfigurationExists(scan->m pName))767 if(!rConfig.SubConfigurationExists(scan->mName)) 676 768 { 677 769 // Should exist, but doesn't. 678 770 ok = false; 679 rErrorMsg += rLevel + rConfig.mName + "." + scan->m pName + " (block) is missing.\n";771 rErrorMsg += rLevel + rConfig.mName + "." + scan->mName + " (block) is missing.\n"; 680 772 } 681 773 } … … 702 794 while(scan) 703 795 { 704 if(s trcmp(scan->mpName, name) == 0)796 if(scan->mName == name) 705 797 { 706 798 // found it! -
box/trunk/lib/common/Configuration.h
r2124 r2127 30 30 { 31 31 public: 32 const char *mpName; // "*" for all other keys (not implemented yet) 33 const char *mpDefaultValue; // default for when it's not present 34 int Tests; 35 void *TestFunction; // set to zero for now, will implement later 32 typedef enum 33 { 34 NoDefaultValue = 1 35 } NoDefaultValue_t; 36 37 ConfigurationVerifyKey(std::string name, int flags, 38 void *testFunction = NULL); 39 // to allow passing ConfigurationVerifyKey::NoDefaultValue 40 // for default ListenAddresses 41 ConfigurationVerifyKey(std::string name, int flags, 42 NoDefaultValue_t t, void *testFunction = NULL); 43 ConfigurationVerifyKey(std::string name, int flags, 44 std::string defaultValue, void *testFunction = NULL); 45 ConfigurationVerifyKey(std::string name, int flags, 46 const char* defaultValue, void *testFunction = NULL); 47 ConfigurationVerifyKey(std::string name, int flags, 48 int defaultValue, void *testFunction = NULL); 49 ConfigurationVerifyKey(std::string name, int flags, 50 bool defaultValue, void *testFunction = NULL); 51 const std::string& Name() const { return mName; } 52 const std::string& DefaultValue() const { return mDefaultValue; } 53 const bool HasDefaultValue() const { return mHasDefaultValue; } 54 const int Flags() const { return mFlags; } 55 const void* TestFunction() const { return mTestFunction; } 56 ConfigurationVerifyKey(const ConfigurationVerifyKey& rToCopy); 57 58 private: 59 ConfigurationVerifyKey& operator=(const ConfigurationVerifyKey& 60 noAssign); 61 62 std::string mName; // "*" for all other keys (not implemented yet) 63 std::string mDefaultValue; // default for when it's not present 64 bool mHasDefaultValue; 65 int mFlags; 66 void *mTestFunction; // set to zero for now, will implement later 36 67 }; 37 68 … … 39 70 { 40 71 public: 41 const char *mpName;// "*" for all other sub config names72 std::string mName; // "*" for all other sub config names 42 73 const ConfigurationVerify *mpSubConfigurations; 43 74 const ConfigurationVerifyKey *mpKeys; 44 75 int Tests; 45 void *TestFunction; // set to zero for now, will implement later76 void *TestFunction; // set to zero for now, will implement later 46 77 }; 47 78 … … 80 111 { return LoadAndVerify(rFilename, 0, rErrorMsg); } 81 112 82 bool KeyExists(const char *pKeyName) const;83 const std::string &GetKeyValue(const char *pKeyName) const;84 int GetKeyValueInt(const char *pKeyName) const;85 bool GetKeyValueBool(const char *pKeyName) const;113 bool KeyExists(const std::string& rKeyName) const; 114 const std::string &GetKeyValue(const std::string& rKeyName) const; 115 int GetKeyValueInt(const std::string& rKeyName) const; 116 bool GetKeyValueBool(const std::string& rKeyName) const; 86 117 std::vector<std::string> GetKeyNames() const; 87 118 88 bool SubConfigurationExists(const char *pSubName) const;89 const Configuration &GetSubConfiguration(const char *pSubName) const;119 bool SubConfigurationExists(const std::string& rSubName) const; 120 const Configuration &GetSubConfiguration(const std::string& rSubName) const; 90 121 std::vector<std::string> GetSubConfigurationNames() const; 91 122 -
box/trunk/lib/common/DebugMemLeakFinder.cpp
r2124 r2127 147 147 if(ptr && i == sMallocBlocks.end()) 148 148 { 149 TRACE1("Block %x realloc(), but not in list. Error? Or allocated in startup static objects?\n", ptr); 149 BOX_WARNING("Block " << ptr << " realloc()ated, but not " 150 "in list. Error? Or allocated in startup static " 151 "objects?"); 150 152 } 151 153 … … 194 196 else 195 197 { 196 TRACE1("Block %p freed, but not known. Error? Or allocated in startup static allocation?\n", ptr); 198 BOX_WARNING("Block " << ptr << " freed, but not " 199 "known. Error? Or allocated in startup " 200 "static allocation?"); 197 201 } 198 202 … … 294 298 if(i == sMallocBlocks.end()) 295 299 { 296 TRACE0("Logical error in section block finding\n");300 BOX_WARNING("Logical error in section block finding"); 297 301 } 298 302 else 299 303 { 300 TRACE4("Block %p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line); 304 BOX_TRACE("Block " << i->first << " size " << 305 i->second.size << " allocated at " << 306 i->second.file << ":" << i->second.line); 301 307 } 302 308 } 303 309 for(std::map<void *, ObjectInfo>::const_iterator i(sSectionObjectBlocks.begin()); i != sSectionObjectBlocks.end(); ++i) 304 310 { 305 TRACE5("Object%s %p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line); 311 BOX_TRACE("Object" << (i->second.array?" []":"") << " " << 312 i->first << " size " << i->second.size << 313 " allocated at " << i->second.file << 314 ":" << i->second.line); 306 315 } 307 316 } -
box/trunk/lib/common/EventWatchFilesystemObject.cpp
r2124 r2127 27 27 // 28 28 // Function 29 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject(const char *) 30 // Purpose: Constructor -- opens the file object 31 // Created: 12/3/04 29 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject 30 // (const char *) 31 // Purpose: Constructor -- opens the file object 32 // Created: 12/3/04 32 33 // 33 34 // -------------------------------------------------------------------------- … … 40 41 if(mDescriptor == -1) 41 42 { 42 BOX_ERROR("EventWatchFilesystemObject: " 43 "Failed to open file '" << Filename << "': " << 44 strerror(errno)); 43 BOX_LOG_SYS_ERROR("EventWatchFilesystemObject: " 44 "Failed to open file '" << Filename << "'"); 45 45 THROW_EXCEPTION(CommonException, OSFileOpenError) 46 46 } … … 54 54 // 55 55 // Function 56 // Name: EventWatchFilesystemObject::~EventWatchFilesystemObject()57 // Purpose: Destructor58 // Created: 12/3/0456 // Name: EventWatchFilesystemObject::~EventWatchFilesystemObject() 57 // Purpose: Destructor 58 // Created: 12/3/04 59 59 // 60 60 // -------------------------------------------------------------------------- … … 71 71 // 72 72 // Function 73 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &) 74 // Purpose: Copy constructor 75 // Created: 12/3/04 73 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject 74 // (const EventWatchFilesystemObject &) 75 // Purpose: Copy constructor 76 // Created: 12/3/04 76 77 // 77 78 // -------------------------------------------------------------------------- 78 EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &rToCopy) 79 EventWatchFilesystemObject::EventWatchFilesystemObject( 80 const EventWatchFilesystemObject &rToCopy) 79 81 : mDescriptor(::dup(rToCopy.mDescriptor)) 80 82 { … … 90 92 // 91 93 // Function 92 // Name: EventWatchFilesystemObject::FillInKEvent(struct kevent &, int)93 // Purpose: For WaitForEvent94 // Created: 12/3/0494 // Name: EventWatchFilesystemObject::FillInKEvent(struct kevent &, int) 95 // Purpose: For WaitForEvent 96 // Created: 12/3/04 95 97 // 96 98 // -------------------------------------------------------------------------- 97 void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, int Flags) const 99 void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, 100 int Flags) const 98 101 { 99 EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, NOTE_DELETE | NOTE_WRITE, 0, (void*)this); 102 EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, 103 NOTE_DELETE | NOTE_WRITE, 0, (void*)this); 100 104 } 101 105 #else 102 void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, int Flags) const 106 void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, 107 int Flags) const 103 108 { 104 109 THROW_EXCEPTION(CommonException, KQueueNotSupportedOnThisPlatform) -
box/trunk/lib/common/FileStream.cpp
r2124 r2127 31 31 : mOSFileHandle(::open(Filename, flags, mode)), 32 32 #endif 33 mIsEOF(false) 33 mIsEOF(false), 34 mFileName(Filename) 34 35 { 35 36 #ifdef WIN32 … … 50 51 } 51 52 } 52 #ifdef WIN3253 this->fileName = Filename;54 #endif55 53 } 56 54 … … 66 64 FileStream::FileStream(tOSFileHandle FileDescriptor) 67 65 : mOSFileHandle(FileDescriptor), 68 mIsEOF(false) 66 mIsEOF(false), 67 mFileName("HANDLE") 69 68 { 70 69 #ifdef WIN32 … … 78 77 THROW_EXCEPTION(CommonException, OSFileOpenError) 79 78 } 80 #ifdef WIN3281 this->fileName = "HANDLE";82 #endif83 79 } 84 80 … … 151 147 ); 152 148 153 if ( valid)149 if(valid) 154 150 { 155 151 r = numBytesRead; 156 152 } 157 else if (GetLastError() == ERROR_BROKEN_PIPE)153 else if(GetLastError() == ERROR_BROKEN_PIPE) 158 154 { 159 155 r = 0; … … 161 157 else 162 158 { 163 BOX_ERROR("Failed to read from file: " << 164 GetErrorMessage(GetLastError())); 159 BOX_LOG_WIN_ERROR("Failed to read from file: " << mFileName); 165 160 r = -1; 166 161 } 167 162 #else 168 163 int r = ::read(mOSFileHandle, pBuffer, NBytes); 169 #endif170 164 if(r == -1) 171 165 { 166 BOX_LOG_SYS_ERROR("Failed to read from file: " << mFileName); 167 } 168 #endif 169 170 if(r == -1) 171 { 172 172 THROW_EXCEPTION(CommonException, OSFileReadError) 173 173 } 174 174 175 if(r == 0) 175 176 { -
box/trunk/lib/common/FileStream.h
r2124 r2127 58 58 FileStream(const FileStream &rToCopy) { /* do not call */ } 59 59 60 #ifdef WIN3261 60 // for debugging.. 62 std::string fileName; 63 #endif 61 std::string mFileName; 64 62 }; 65 63 -
box/trunk/lib/common/Guards.h
r2124 r2127 38 38 if(mOSFileHandle < 0) 39 39 { 40 BOX_ ERROR("FileHandleGuard: failed to open file '" <<41 rFilename << "': " << strerror(errno));40 BOX_LOG_SYS_ERROR("FileHandleGuard: failed to open " 41 "file '" << rFilename << "'"); 42 42 THROW_EXCEPTION(CommonException, OSFileOpenError) 43 43 } -
box/trunk/lib/common/Logging.h
r2124 r2127 28 28 #define BOX_LOG(level, stuff) \ 29 29 { \ 30 std::ostringstream line; \31 line << stuff; \32 Logging::Log(level, __FILE__, __LINE__, line.str()); \30 std::ostringstream _box_log_line; \ 31 _box_log_line << stuff; \ 32 Logging::Log(level, __FILE__, __LINE__, _box_log_line.str()); \ 33 33 } 34 34 35 35 #define BOX_SYSLOG(level, stuff) \ 36 36 { \ 37 std::ostringstream line; \38 line << stuff; \39 Logging::LogToSyslog(level, __FILE__, __LINE__, line.str()); \37 std::ostringstream _box_log_line; \ 38 _box_log_line << stuff; \ 39 Logging::LogToSyslog(level, __FILE__, __LINE__, _box_log_line.str()); \ 40 40 } 41 41 … … 49 49 { BOX_LOG(Log::TRACE, stuff) } 50 50 51 #define BOX_FORMAT_ACCOUNT(accno) \ 51 #define BOX_LOG_SYS_WARNING(stuff) \ 52 BOX_WARNING(stuff << ": " << strerror(errno) << " (" << errno << ")") 53 #define BOX_LOG_SYS_ERROR(stuff) \ 54 BOX_ERROR(stuff << ": " << strerror(errno) << " (" << errno << ")") 55 #define BOX_LOG_SYS_FATAL(stuff) \ 56 BOX_FATAL(stuff << ": " << strerror(errno) << " (" << errno << ")") 57 58 #ifdef WIN32 59 #define BOX_LOG_WIN_ERROR(stuff) \ 60 BOX_ERROR(stuff << ": " << GetErrorMessage(GetLastError())) 61 #define BOX_LOG_WIN_ERROR_NUMBER(stuff, number) \ 62 BOX_ERROR(stuff << ": " << GetErrorMessage(number)) 63 #endif 64 65 #define BOX_FORMAT_HEX32(number) \ 52 66 std::hex << \ 53 67 std::showbase << \ … … 55 69 std::setw(10) << \ 56 70 std::setfill('0') << \ 57 ( accno) << \71 (number) << \ 58 72 std::dec 73 74 #define BOX_FORMAT_ACCOUNT(accno) \ 75 BOX_FORMAT_HEX32(accno) 59 76 60 77 #define BOX_FORMAT_OBJECTID(objectid) \ -
box/trunk/lib/common/PartialReadStream.cpp
r2124 r2127 45 45 if(mBytesLeft != 0) 46 46 { 47 TRACE1("PartialReadStream::~PartialReadStream when mBytesLeft = %d\n", mBytesLeft); 47 BOX_TRACE("PartialReadStream destroyed with " << mBytesLeft << 48 " bytes remaining"); 48 49 } 49 50 } -
box/trunk/lib/common/Utils.cpp
r2124 r2127 54 54 } 55 55 /*#ifndef NDEBUG 56 TRACE2("Splitting string '%s' on %c\n", String.c_str(),SplitOn);56 BOX_TRACE("Splitting string '" << String << " on " << (char)SplitOn); 57 57 for(unsigned int l = 0; l < rOutput.size(); ++l) 58 58 { 59 TRACE2("%d = '%s'\n", l, rOutput[l].c_str());59 BOX_TRACE(l << " = '" << rOutput[l] << "'"); 60 60 } 61 61 #endif*/ … … 160 160 } 161 161 162 163 164 162 std::string HumanReadableSize(int64_t Bytes) 163 { 164 double readableValue = Bytes; 165 std::string units = " B"; 166 167 if (readableValue > 1024) 168 { 169 readableValue /= 1024; 170 units = "kB"; 171 } 172 173 if (readableValue > 1024) 174 { 175 readableValue /= 1024; 176 units = "MB"; 177 } 178 179 if (readableValue > 1024) 180 { 181 readableValue /= 1024; 182 units = "GB"; 183 } 184 185 std::ostringstream result; 186 result << std::fixed << std::setprecision(2) << readableValue << 187 " " << units; 188 return result.str(); 189 } 190 191 std::string FormatUsageBar(int64_t Blocks, int64_t Bytes, int64_t Max) 192 { 193 std::ostringstream result; 194 195 // Bar graph 196 char bar[17]; 197 unsigned int b = (int)((Bytes * (sizeof(bar)-1)) / Max); 198 if(b > sizeof(bar)-1) {b = sizeof(bar)-1;} 199 for(unsigned int l = 0; l < b; l++) 200 { 201 bar[l] = '*'; 202 } 203 for(unsigned int l = b; l < sizeof(bar) - 1; l++) 204 { 205 bar[l] = ' '; 206 } 207 bar[sizeof(bar)-1] = '\0'; 208 209 result << std::fixed << 210 std::setw(10) << Blocks << " blocks, " << 211 std::setw(10) << HumanReadableSize(Bytes) << ", " << 212 std::setw(3) << std::setprecision(0) << 213 ((Bytes*100)/Max) << "% |" << bar << "|"; 214 215 return result.str(); 216 } 217 218 std::string FormatUsageLineStart(const std::string& rName) 219 { 220 std::ostringstream result; 221 result << std::setw(20) << std::right << rName << ": "; 222 return result.str(); 223 } -
box/trunk/lib/common/Utils.h
r2124 r2127 31 31 }; 32 32 int ObjectExists(const std::string& rFilename); 33 std::string HumanReadableSize(int64_t Bytes); 34 std::string FormatUsageBar(int64_t Blocks, int64_t Bytes, int64_t Max); 35 std::string FormatUsageLineStart(const std::string& rName); 33 36 34 37 #include "MemLeakFindOff.h" -
box/trunk/lib/compress/Compress.h
r2124 r2127 53 53 :(inflateEnd(&mStream)))) != Z_OK) 54 54 { 55 TRACE1("zlib error code = %d\n",r);55 BOX_WARNING("zlib error code = " << r); 56 56 if(r == Z_DATA_ERROR) 57 57 { 58 TRACE0("WARNING: End of compress/decompress without all input being consumed -- possible corruption?\n"); 58 BOX_WARNING("End of compress/decompress " 59 "without all input being consumed, " 60 "possible corruption?"); 59 61 } 60 62 else … … 149 151 if(ret < 0) 150 152 { 151 TRACE1("zlib error code = %d\n",ret);153 BOX_WARNING("zlib error code = " << ret); 152 154 THROW_EXCEPTION(CompressException, TransformFailed) 153 155 } -
box/trunk/lib/compress/CompressStream.cpp
r2124 r2127 415 415 size *= 2; 416 416 } 417 TRACE1("Allocating CompressStream buffer, size %d\n",size);417 BOX_TRACE("Allocating CompressStream buffer, size " << size); 418 418 mpBuffer = ::malloc(size); 419 419 if(mpBuffer == 0) -
box/trunk/lib/crypto/CipherContext.cpp
r2124 r2127 167 167 if(mWithinTransform) 168 168 { 169 TRACE0("CipherContext::Begin called when context flagged as within a transform\n"); 169 BOX_WARNING("CipherContext::Begin called when context " 170 "flagged as within a transform"); 170 171 } 171 172 … … 424 425 if(mWithinTransform) 425 426 { 426 TRACE0("CipherContext::TransformBlock called when context flagged as within a transform\n"); 427 BOX_WARNING("CipherContext::TransformBlock called when " 428 "context flagged as within a transform"); 427 429 } 428 430 … … 522 524 if(mWithinTransform) 523 525 { 524 TRACE0("CipherContext::SetIV called when context flagged as within a transform\n"); 526 BOX_WARNING("CipherContext::SetIV called when context " 527 "flagged as within a transform"); 525 528 } 526 529 … … 560 563 if(mWithinTransform) 561 564 { 562 TRACE0("CipherContext::SetRandomIV called when context flagged as within a transform\n"); 565 BOX_WARNING("CipherContext::SetRandomIV called when " 566 "context flagged as within a transform"); 563 567 } 564 568 -
box/trunk/lib/intercept/intercept.cpp
r2124 r2127 376 376 if (hookfn != NULL) 377 377 { 378 TRACE2("readdir hooked to %p for %s\n", hookfn,dirname);378 BOX_TRACE("readdir hooked to " << hookfn << " for " << dirname); 379 379 } 380 380 else if (intercept_filename != NULL) 381 381 { 382 TRACE2("readdir unhooked from %p for %s\n", readdir_hook,383 intercept_filename);382 BOX_TRACE("readdir unhooked from " << readdir_hook << 383 " for " << intercept_filename); 384 384 } 385 385 … … 393 393 if (hookfn != NULL) 394 394 { 395 TRACE2("lstat hooked to %p for %s\n", hookfn,filename);395 BOX_TRACE("lstat hooked to " << hookfn << " for " << filename); 396 396 } 397 397 else 398 398 { 399 TRACE2("lstat unhooked from %p for %s\n", lstat_hook,399 BOX_TRACE("lstat unhooked from " << lstat_hook << " for " << 400 400 lstat_file); 401 401 } -
box/trunk/lib/raidfile/RaidFileController.cpp
r2124 r2127 71 71 static const ConfigurationVerifyKey verifykeys[] = 72 72 { 73 {"SetNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 74 {"BlockSize", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 75 {"Dir0", 0, ConfigTest_Exists, 0}, 76 {"Dir1", 0, ConfigTest_Exists, 0}, 77 {"Dir2", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0} 73 ConfigurationVerifyKey("SetNumber", 74 ConfigTest_Exists | ConfigTest_IsInt), 75 ConfigurationVerifyKey("BlockSize", 76 ConfigTest_Exists | ConfigTest_IsInt), 77 ConfigurationVerifyKey("Dir0", ConfigTest_Exists), 78 ConfigurationVerifyKey("Dir1", ConfigTest_Exists), 79 ConfigurationVerifyKey("Dir2", 80 ConfigTest_Exists | ConfigTest_LastEntry) 78 81 }; 79 82 -
box/trunk/lib/raidfile/RaidFileWrite.cpp
r2124 r2127 97 97 if(existance != RaidFileUtil::NoFile) 98 98 { 99 TRACE2("Trying to overwrite raidfile %d %s\n", mSetNumber, mFilename.c_str()); 99 BOX_ERROR("Attempted to overwrite raidfile " << 100 mSetNumber << " " << mFilename); 100 101 THROW_EXCEPTION(RaidFileException, CannotOverwriteExistingFile) 101 102 } … … 179 180 if(written != Length) 180 181 { 181 TRACE3("RaidFileWrite::Write: Write failure, Length = %d, written = %d, errno = %d\n", Length, written, errno); 182 BOX_LOG_SYS_ERROR("RaidFileWrite failed, Length = " << 183 Length << ", written = " << written); 182 184 THROW_EXCEPTION(RaidFileException, OSError) 183 185 } … … 780 782 void RaidFileWrite::Close() 781 783 { 782 TRACE0("Warning: RaidFileWrite::Close() called, discarding file\n");784 BOX_WARNING("RaidFileWrite::Close() called, discarding file"); 783 785 if(mOSFileHandle != -1) 784 786 { -
box/trunk/lib/server/Daemon.cpp
r2124 r2127 466 466 if(::setsid() == -1) 467 467 { 468 BOX_ERROR("Failed to setsid(): " << 469 strerror(errno)); 468 BOX_LOG_SYS_ERROR("Failed to setsid()"); 470 469 THROW_EXCEPTION(ServerException, DaemoniseFailed) 471 470 } … … 476 475 case -1: 477 476 // error 477 BOX_LOG_SYS_ERROR("Failed to fork() a child"); 478 478 THROW_EXCEPTION(ServerException, DaemoniseFailed) 479 479 break; … … 498 498 sa.sa_handler = SignalHandler; 499 499 sa.sa_flags = 0; 500 sigemptyset(&sa.sa_mask); // macro 501 if(::sigaction(SIGHUP, &sa, NULL) != 0 || ::sigaction(SIGTERM, &sa, NULL) != 0) 502 { 500 sigemptyset(&sa.sa_mask); // macro 501 if(::sigaction(SIGHUP, &sa, NULL) != 0 || 502 ::sigaction(SIGTERM, &sa, NULL) != 0) 503 { 504 BOX_LOG_SYS_ERROR("Failed to set signal handlers"); 503 505 THROW_EXCEPTION(ServerException, DaemoniseFailed) 504 506 } … … 516 518 if(::write(pidFile, pid, pidsize) != pidsize) 517 519 { 518 BOX_FATAL("can't write pid file"); 520 BOX_LOG_SYS_FATAL("Failed to write PID file: " << 521 pidFileName); 519 522 THROW_EXCEPTION(ServerException, DaemoniseFailed) 520 523 } … … 545 548 if(devnull == -1) 546 549 { 550 BOX_LOG_SYS_ERROR("Failed to open /dev/null"); 547 551 THROW_EXCEPTION(CommonException, OSFileError); 548 552 } … … 891 895 return 0; 892 896 } 897 BOX_LOG_SYS_ERROR("Failed to stat configuration file: " << 898 GetConfigFileName()); 893 899 THROW_EXCEPTION(CommonException, OSFileError) 894 900 } -
box/trunk/lib/server/Daemon.h
r2124 r2127 93 93 }; 94 94 95 #define DAEMON_VERIFY_SERVER_KEYS {"PidFile", 0, ConfigTest_Exists, 0}, \ 96 {"User", 0, ConfigTest_LastEntry, 0} 95 #define DAEMON_VERIFY_SERVER_KEYS \ 96 ConfigurationVerifyKey("PidFile", ConfigTest_Exists), \ 97 ConfigurationVerifyKey("User", ConfigTest_LastEntry) 97 98 98 99 #endif // DAEMON__H -
box/trunk/lib/server/ProtocolUncertainStream.cpp
r2124 r2127 42 42 if(!mFinished) 43 43 { 44 TRACE0("ProtocolUncertainStream::~ProtocolUncertainStream() destroyed when stream not complete\n"); 44 BOX_WARNING("ProtocolUncertainStream destroyed before " 45 "stream finished"); 45 46 } 46 47 } -
box/trunk/lib/server/ServerControl.h
r2124 r2127 143 143 if (!killed) 144 144 { 145 BOX_ERROR("Failed to kill process " << pid << ": " << 146 strerror(errno)); 145 BOX_LOG_SYS_ERROR("Failed to kill process " << pid); 147 146 } 148 147 TEST_THAT(killed); -
box/trunk/lib/server/ServerStream.h
r2124 r2127 274 274 275 275 // Log it 276 BOX_ WARNING("Message from child process " << pid << ": " << logMessage);276 BOX_NOTICE("Message from child process " << pid << ": " << logMessage); 277 277 } 278 278 else … … 366 366 367 367 #define SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \ 368 {"ListenAddresses", DEFAULT_ADDRESSES, 0, 0}, \369 DAEMON_VERIFY_SERVER_KEYS368 ConfigurationVerifyKey("ListenAddresses", 0, DEFAULT_ADDRESSES), \ 369 DAEMON_VERIFY_SERVER_KEYS 370 370 371 371 #include "MemLeakFindOff.h" -
box/trunk/lib/server/ServerTLS.h
r2124 r2127 71 71 72 72 #define SERVERTLS_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \ 73 {"CertificateFile", 0, ConfigTest_Exists, 0}, \ 74 {"PrivateKeyFile", 0, ConfigTest_Exists, 0}, \ 75 {"TrustedCAsFile", 0, ConfigTest_Exists, 0}, \ 76 SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) 77 73 ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists), \ 74 ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists), \ 75 ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists), \ 76 SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) 78 77 79 78 #endif // SERVERTLS__H -
box/trunk/lib/server/SocketListen.h
r2124 r2127 109 109 #endif 110 110 { 111 THROW_EXCEPTION(ServerException, SocketCloseError) 111 BOX_LOG_SYS_ERROR("Failed to close network " 112 "socket"); 113 THROW_EXCEPTION(ServerException, 114 SocketCloseError) 112 115 } 113 116 } … … 115 118 } 116 119 117 // ------------------------------------------------------------------ --------120 // ------------------------------------------------------------------ 118 121 // 119 122 // Function … … 122 125 // Created: 2003/07/31 123 126 // 124 // ------------------------------------------------------------------ --------127 // ------------------------------------------------------------------ 125 128 void Listen(int Type, const char *Name, int Port = 0) 126 129 { 127 if(mSocketHandle != -1) {THROW_EXCEPTION(ServerException, SocketAlreadyOpen)} 130 if(mSocketHandle != -1) 131 { 132 THROW_EXCEPTION(ServerException, SocketAlreadyOpen); 133 } 128 134 129 135 // Setup parameters based on type, looking up names if required … … 131 137 SocketAllAddr addr; 132 138 int addrLen = 0; 133 Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name, Port, addrLen); 139 Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name, 140 Port, addrLen); 134 141 135 142 // Create the socket 136 mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 0 /* let OS choose protocol */); 143 mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 144 0 /* let OS choose protocol */); 137 145 if(mSocketHandle == -1) 138 146 { 147 BOX_LOG_SYS_ERROR("Failed to create a network socket"); 139 148 THROW_EXCEPTION(ServerException, SocketOpenError) 140 149 } … … 142 151 // Set an option to allow reuse (useful for -HUP situations!) 143 152 #ifdef WIN32 144 if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "", 0) == -1) 153 if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "", 154 0) == -1) 145 155 #else 146 156 int option = true; 147 if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) == -1) 148 #endif 149 { 157 if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, 158 &option, sizeof(option)) == -1) 159 #endif 160 { 161 BOX_LOG_SYS_ERROR("Failed to set socket options"); 150 162 THROW_EXCEPTION(ServerException, SocketOpenError) 151 163 } … … 162 174 } 163 175 164 // ------------------------------------------------------------------ --------176 // ------------------------------------------------------------------ 165 177 // 166 178 // Function 167 179 // Name: SocketListen::Accept(int) 168 // Purpose: Accepts a connection, returning a pointer to a class of 169 // the specified type. May return a null pointer if a signal happens, 170 // or there's a timeout. Timeout specified in milliseconds, defaults to infinite time. 180 // Purpose: Accepts a connection, returning a pointer to 181 // a class of the specified type. May return a 182 // null pointer if a signal happens, or there's 183 // a timeout. Timeout specified in 184 // milliseconds, defaults to infinite time. 171 185 // Created: 2003/07/31 172 186 // 173 // -------------------------------------------------------------------------- 174 std::auto_ptr<SocketType> Accept(int Timeout = INFTIM, std::string *pLogMsg = 0) 175 { 176 if(mSocketHandle == -1) {THROW_EXCEPTION(ServerException, BadSocketHandle)} 187 // ------------------------------------------------------------------ 188 std::auto_ptr<SocketType> Accept(int Timeout = INFTIM, 189 std::string *pLogMsg = 0) 190 { 191 if(mSocketHandle == -1) 192 { 193 THROW_EXCEPTION(ServerException, BadSocketHandle); 194 } 177 195 178 196 // Do the accept, using the supplied locking type … … 186 204 if(!socklock.HaveLock()) 187 205 { 188 // Didn't get the lock for some reason. Wait a while, then 189 // return nothing. 206 // Didn't get the lock for some reason. 207 // Wait a while, then return nothing. 208 BOX_ERROR("Failed to get a lock on incoming " 209 "connection"); 190 210 ::sleep(1); 191 211 return std::auto_ptr<SocketType>(); … … 203 223 if(errno == EINTR) 204 224 { 225 BOX_ERROR("Failed to accept " 226 "connection: interrupted by " 227 "signal"); 205 228 // return nothing 206 229 return std::auto_ptr<SocketType>(); … … 208 231 else 209 232 { 210 THROW_EXCEPTION(ServerException, SocketPollError) 233 BOX_LOG_SYS_ERROR("Failed to poll " 234 "connection"); 235 THROW_EXCEPTION(ServerException, 236 SocketPollError) 211 237 } 212 238 break; … … 221 247 sock = ::accept(mSocketHandle, &addr, &addrlen); 222 248 } 223 // Got socket (or error), unlock (implcit in destruction) 249 250 // Got socket (or error), unlock (implicit in destruction) 224 251 if(sock == -1) 225 252 { 253 BOX_LOG_SYS_ERROR("Failed to accept connection"); 226 254 THROW_EXCEPTION(ServerException, SocketAcceptError) 227 255 } … … 230 258 if(pLogMsg) 231 259 { 232 *pLogMsg = Socket::IncomingConnectionLogMessage(&addr, addrlen); 260 *pLogMsg = Socket::IncomingConnectionLogMessage(&addr, 261 addrlen); 233 262 } 234 263 else … … 244 273 // on multiple sockets. 245 274 #ifdef HAVE_KQUEUE 246 // ------------------------------------------------------------------ --------275 // ------------------------------------------------------------------ 247 276 // 248 277 // Function … … 251 280 // Created: 9/3/04 252 281 // 253 // ------------------------------------------------------------------ --------282 // ------------------------------------------------------------------ 254 283 void FillInKEvent(struct kevent &rEvent, int Flags = 0) const 255 284 { 256 EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0, (void*)this); 285 EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0, 286 (void*)this); 257 287 } 258 288 #else 259 // ------------------------------------------------------------------ --------289 // ------------------------------------------------------------------ 260 290 // 261 291 // Function 262 292 // Name: SocketListen::FillInPoll 263 // Purpose: Fills in the data necessary for a poll operation 293 // Purpose: Fills in the data necessary for a poll 294 // operation 264 295 // Created: 9/3/04 265 296 // 266 // ------------------------------------------------------------------ --------297 // ------------------------------------------------------------------ 267 298 void FillInPoll(int &fd, short &events, int Flags = 0) const 268 299 { -
box/trunk/lib/server/SocketStream.cpp
r2124 r2127 151 151 152 152 // Create the socket 153 mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 0 /* let OS choose protocol */); 153 mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 154 0 /* let OS choose protocol */); 154 155 if(mSocketHandle == INVALID_SOCKET_VALUE) 155 156 { 157 BOX_LOG_SYS_ERROR("Failed to create a network socket"); 156 158 THROW_EXCEPTION(ServerException, SocketOpenError) 157 159 } … … 164 166 DWORD err = WSAGetLastError(); 165 167 ::closesocket(mSocketHandle); 166 #else 167 int err = errno; 168 BOX_LOG_WIN_ERROR_NUMBER("Failed to connect to socket " 169 "(type " << Type << ", name " << Name << 170 ", port " << Port << ")", err); 171 #else // !WIN32 172 BOX_LOG_SYS_ERROR("Failed to connect to socket (type " << 173 Type << ", name " << Name << ", port " << Port << 174 ")"); 168 175 ::close(mSocketHandle); 169 #endif 170 171 #ifdef WIN32 172 BOX_ERROR("Failed to connect to socket (type " << Type << 173 ", name " << Name << ", port " << Port << "): " << 174 GetErrorMessage(err) 175 ); 176 #else 177 BOX_ERROR("Failed to connect to socket (type " << Type << 178 ", name " << Name << ", port " << Port << "): " << 179 strerror(err) << " (" << err << ")" 180 ); 181 #endif 176 #endif // WIN32 182 177 183 178 mSocketHandle = INVALID_SOCKET_VALUE; … … 221 216 { 222 217 // Bad! 223 THROW_EXCEPTION(ServerException, SocketPollError) 218 BOX_LOG_SYS_ERROR("Failed to poll socket"); 219 THROW_EXCEPTION(ServerException, 220 SocketPollError) 224 221 } 225 222 break; … … 251 248 { 252 249 // Other error 253 THROW_EXCEPTION(ConnectionException, Conn_SocketReadError) 250 BOX_LOG_SYS_ERROR("Failed to read from socket"); 251 THROW_EXCEPTION(ConnectionException, 252 Conn_SocketReadError); 254 253 } 255 254 } 255 256 256 // Closed for reading? 257 257 if(r == 0) … … 298 298 // Error. 299 299 mWriteClosed = true; // assume can't write again 300 THROW_EXCEPTION(ConnectionException, Conn_SocketWriteError) 300 BOX_LOG_SYS_ERROR("Failed to write to socket"); 301 THROW_EXCEPTION(ConnectionException, 302 Conn_SocketWriteError); 301 303 } 302 304 … … 311 313 if(bytesLeft > 0) 312 314 { 313 TRACE3("Waiting to send data on socket %d, (%d to send of %d)\n", mSocketHandle, bytesLeft, NBytes); 315 BOX_TRACE("Waiting to send data on socket " << 316 mSocketHandle << " (" << bytesLeft << 317 " of " << NBytes << " bytes left)"); 314 318 315 319 // Wait for data to send. … … 324 328 if(errno != EINTR) 325 329 { 326 THROW_EXCEPTION(ServerException, SocketPollError) 330 BOX_LOG_SYS_ERROR("Failed to poll " 331 "socket"); 332 THROW_EXCEPTION(ServerException, 333 SocketPollError) 327 334 } 328 335 } … … 351 358 #endif 352 359 { 360 BOX_LOG_SYS_ERROR("Failed to close socket"); 353 361 THROW_EXCEPTION(ServerException, SocketCloseError) 354 362 } … … 381 389 if(::shutdown(mSocketHandle, how) == -1) 382 390 { 391 BOX_LOG_SYS_ERROR("Failed to shutdown socket"); 383 392 THROW_EXCEPTION(ConnectionException, Conn_SocketShutdownError) 384 393 } … … 459 468 socklen_t credLen = sizeof(cred); 460 469 461 if(::getsockopt(mSocketHandle, SOL_SOCKET, SO_PEERCRED, &cred, &credLen) == 0) 470 if(::getsockopt(mSocketHandle, SOL_SOCKET, SO_PEERCRED, &cred, 471 &credLen) == 0) 462 472 { 463 473 rUidOut = cred.uid; … … 465 475 return true; 466 476 } 477 478 BOX_LOG_SYS_ERROR("Failed to get peer credentials on socket"); 467 479 #endif 468 480 -
box/trunk/test/backupdiff/testbackupdiff.cpp
r2124 r2127 111 111 // number of blocks 112 112 int64_t nblocks = box_ntoh64(hdr.mNumBlocks); 113 TRACE2("Reading index from '%s', has %lld blocks\n", filename, nblocks); 114 TRACE0("======== ===== ========== ======== ========\n Index Where EncSz/Idx Size WChcksm\n"); 113 BOX_TRACE("Reading index from '" << filename << "', has " << 114 nblocks << " blocks"); 115 BOX_TRACE("======== ===== ========== ======== ========"); 116 BOX_TRACE(" Index Where EncSz/Idx Size WChcksm"); 115 117 // Read them all in 116 118 int64_t nnew = 0, nold = 0; … … 120 122 TEST_THAT(enc.ReadFullBuffer(&en, sizeof(en), 0)); 121 123 int64_t s = box_ntoh64(en.mEncodedSize); 122 if(s > 0) 123 { 124 nnew++; 125 #ifdef WIN32 126 TRACE2("%8I64d this s=%8I64d", b, s); 127 #else 128 TRACE2("%8lld this s=%8lld", b, s); 129 #endif 130 } 131 else 132 { 133 nold++; 134 #ifdef WIN32 135 TRACE2("%8I64d other i=%8I64d", b, 0 - s); 136 #else 137 TRACE2("%8lld other i=%8lld", b, 0 - s); 138 #endif 139 } 124 140 125 // Decode the rest 141 126 uint64_t iv = box_ntoh64(hdr.mEntryIVBase); 142 127 iv += b; 143 sBlowfishDecryptBlockEntry.SetIV(&iv); 128 sBlowfishDecryptBlockEntry.SetIV(&iv); 144 129 file_BlockIndexEntryEnc entryEnc; 145 sBlowfishDecryptBlockEntry.TransformBlock(&entryEnc, sizeof(entryEnc), 146 en.mEnEnc, sizeof(en.mEnEnc)); 147 TRACE2(" %8d %08x\n", ntohl(entryEnc.mSize), ntohl(entryEnc.mWeakChecksum)); 148 149 } 150 TRACE0("======== ===== ========== ======== ========\n"); 130 sBlowfishDecryptBlockEntry.TransformBlock(&entryEnc, 131 sizeof(entryEnc), en.mEnEnc, sizeof(en.mEnEnc)); 132 133 134 if(s > 0) 135 { 136 nnew++; 137 BOX_TRACE(std::setw(8) << b << " this s=" << 138 std::setw(8) << s << " " << 139 std::setw(8) << ntohl(entryEnc.mSize) << " " << 140 std::setw(8) << std::setfill('0') << 141 std::hex << ntohl(entryEnc.mWeakChecksum)); 142 } 143 else 144 { 145 nold++; 146 BOX_TRACE(std::setw(8) << b << " other i=" << 147 std::setw(8) << (0-s) << " " << 148 std::setw(8) << ntohl(entryEnc.mSize) << " " << 149 std::setw(8) << std::setfill('0') << 150 std::hex << ntohl(entryEnc.mWeakChecksum)); 151 } 152 } 153 BOX_TRACE("======== ===== ========== ======== ========"); 151 154 TEST_THAT(new_blocks_expected == nnew); 152 155 TEST_THAT(old_blocks_expected == nold); -
box/trunk/test/basicserver/testbasicserver.cpp
r2124 r2127 186 186 static ConfigurationVerifyKey verifyserverkeys[] = 187 187 { 188 SERVERSTREAM_VERIFY_SERVER_KEYS( 0) // no defaultaddresses188 SERVERSTREAM_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses 189 189 }; 190 190 … … 259 259 static ConfigurationVerifyKey verifyserverkeys[] = 260 260 { 261 SERVERTLS_VERIFY_SERVER_KEYS( 0)// no default listen addresses261 SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses 262 262 }; 263 263 -
box/trunk/test/bbackupd/testbbackupd.cpp
r2124 r2127 515 515 // connect and log in 516 516 SocketStreamTLS conn; 517 conn.Open(context, Socket::TypeINET, "localhost", BOX_PORT_BBSTORED); 517 conn.Open(context, Socket::TypeINET, "localhost", 518 22011); 518 519 BackupProtocolClient protocol(conn); 519 520 protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); … … 608 609 { 609 610 sSocket.Open(rContext, Socket::TypeINET, 610 "localhost", BOX_PORT_BBSTORED);611 "localhost", 22011); 611 612 std::auto_ptr<BackupProtocolClient> connection; 612 613 connection.reset(new BackupProtocolClient(sSocket)); … … 2560 2561 == Restore_TargetExists); 2561 2562 2562 // Make sure you can't restore to a nonexistant path2563 printf("Try to restore to a path that doesn't exist\n");2564 TEST_THAT(BackupClientRestore(*client, restoredirid,2565 "testfiles/no-such-path/subdir",2566 true /* print progress dots */)2567 == Restore_TargetPathNotFound);2568 2569 2563 // Find ID of the deleted directory 2570 2564 deldirid = GetDirID(*client, "x1", restoredirid); … … 2578 2572 true /* deleted files */) 2579 2573 == Restore_Complete); 2574 2575 // Make sure you can't restore to a nonexistant path 2576 printf("\n\n==== Try to restore to a path " 2577 "that doesn't exist\n"); 2578 fflush(stdout); 2579 TEST_THAT(BackupClientRestore(*client, restoredirid, 2580 "testfiles/no-such-path/subdir", 2581 true /* print progress dots */) 2582 == Restore_TargetPathNotFound); 2580 2583 2581 2584 // Log out -
box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf
r2124 r2127 9 9 10 10 StoreHostname = localhost 11 StorePort = 22011 11 12 AccountNumber = 0x01234567 12 13 -
box/trunk/test/bbackupd/testfiles/bbackupd.conf.in
r2124 r2127 9 9 10 10 StoreHostname = localhost 11 StorePort = 22011 11 12 AccountNumber = 0x01234567 12 13 -
box/trunk/test/bbackupd/testfiles/bbstored.conf
r2124 r2127 10 10 { 11 11 PidFile = testfiles/bbstored.pid 12 ListenAddresses = inet:localhost 12 ListenAddresses = inet:localhost:22011 13 13 CertificateFile = testfiles/serverCerts.pem 14 14 PrivateKeyFile = testfiles/serverPrivKey.pem -
box/trunk/test/common/testcommon.cpp
r2124 r2127 58 58 ConfigurationVerifyKey verifykeys1_1_1[] = 59 59 { 60 {"bing", 0, ConfigTest_Exists, 0},61 {"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},62 {"terrible", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}60 ConfigurationVerifyKey("bing", ConfigTest_Exists), 61 ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt), 62 ConfigurationVerifyKey("terrible", ConfigTest_Exists | ConfigTest_LastEntry) 63 63 }; 64 64 65 65 ConfigurationVerifyKey verifykeys1_1_2[] = 66 66 { 67 {"fish", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},68 {"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}67 ConfigurationVerifyKey("fish", ConfigTest_Exists | ConfigTest_IsInt), 68 ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry) 69 69 }; 70 70 … … 90 90 ConfigurationVerifyKey verifykeys1_1[] = 91 91 { 92 {"value", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},93 {"string1", 0, ConfigTest_Exists, 0},94 {"string2", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}92 ConfigurationVerifyKey("value", ConfigTest_Exists | ConfigTest_IsInt), 93 ConfigurationVerifyKey("string1", ConfigTest_Exists), 94 ConfigurationVerifyKey("string2", ConfigTest_Exists | ConfigTest_LastEntry) 95 95 }; 96 96 97 97 ConfigurationVerifyKey verifykeys1_2[] = 98 98 { 99 {"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},100 {"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}99 ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt), 100 ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry) 101 101 }; 102 102 … … 121 121 ConfigurationVerifyKey verifykeys1[] = 122 122 { 123 {"notExpected", 0, 0, 0}, 124 {"HasDefaultValue", "Lovely default value", 0, 0}, 125 {"MultiValue", 0, ConfigTest_MultiValueAllowed, 0}, 126 {"BoolTrue1", 0, ConfigTest_IsBool, 0}, 127 {"BoolTrue2", 0, ConfigTest_IsBool, 0}, 128 {"BoolFalse1", 0, ConfigTest_IsBool, 0}, 129 {"BoolFalse2", 0, ConfigTest_IsBool, 0}, 130 {"TOPlevel", 0, ConfigTest_LastEntry | ConfigTest_Exists, 0} 123 ConfigurationVerifyKey("notExpected", 0), 124 ConfigurationVerifyKey("HasDefaultValue", 0, "Lovely default value"), 125 ConfigurationVerifyKey("MultiValue", ConfigTest_MultiValueAllowed), 126 ConfigurationVerifyKey("BoolTrue1", ConfigTest_IsBool), 127 ConfigurationVerifyKey("BoolTrue2", ConfigTest_IsBool), 128 ConfigurationVerifyKey("BoolFalse1", ConfigTest_IsBool), 129 ConfigurationVerifyKey("BoolFalse2", ConfigTest_IsBool), 130 ConfigurationVerifyKey("TOPlevel", 131 ConfigTest_LastEntry | ConfigTest_Exists) 131 132 }; 132 133 -
box/trunk/test/compress/testcompress.cpp
r2124 r2127 91 91 // Check sizes 92 92 TEST_THAT(poutput->GetSize() < source.GetSize()); 93 TRACE2("compressed size = %d, source size = %d\n", poutput->GetSize(), source.GetSize()); 93 BOX_TRACE("compressed size = " << poutput->GetSize() << 94 ", source size = " << source.GetSize()); 94 95 95 96 // Decompress the data -
box/trunk/test/raidfile/testraidfile.cpp
r2124 r2127 623 623 TEST_THAT(n1 != n3); 624 624 TEST_THAT(n1 == n4); // ie wraps around 625 TRACE3("Gen paths= '%s','%s',%s'\n", n1.c_str(), n2.c_str(), n3.c_str()); 625 BOX_TRACE("Gen paths = '" << n1 << "', '" << n2 << 626 "', '" << n3); 626 627 } 627 628
Note: See TracChangeset
for help on using the changeset viewer.
