Skip to content

Commit

Permalink
Merge branch 'master' into fix_arm_struct_packing
Browse files Browse the repository at this point in the history
  • Loading branch information
qris committed Sep 21, 2015
2 parents 00bfaec + 72bff4f commit 9774ed7
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 340 deletions.
22 changes: 15 additions & 7 deletions bin/bbackupd/BackupClientContext.cpp
Expand Up @@ -247,6 +247,11 @@ BackupProtocolCallable &BackupClientContext::GetConnection()
return *mapConnection;
}

BackupProtocolCallable* BackupClientContext::GetOpenConnection() const
{
return mapConnection.get();
}

// --------------------------------------------------------------------------
//
// Function
Expand All @@ -257,18 +262,19 @@ BackupProtocolCallable &BackupClientContext::GetConnection()
// --------------------------------------------------------------------------
void BackupClientContext::CloseAnyOpenConnection()
{
if(mapConnection.get())
BackupProtocolCallable* pConnection(GetOpenConnection());
if(pConnection)
{
try
{
// Quit nicely
mapConnection->QueryFinished();
pConnection->QueryFinished();
}
catch(...)
{
// Ignore errors here
}

// Delete it anyway.
mapConnection.reset();
}
Expand Down Expand Up @@ -299,9 +305,10 @@ void BackupClientContext::CloseAnyOpenConnection()
// --------------------------------------------------------------------------
int BackupClientContext::GetTimeout() const
{
if(mapConnection.get())
BackupProtocolCallable* pConnection(GetOpenConnection());
if(pConnection)
{
return mapConnection->GetTimeout();
return pConnection->GetTimeout();
}

return (15*60*1000);
Expand Down Expand Up @@ -543,7 +550,8 @@ void BackupClientContext::UnManageDiffProcess()
// --------------------------------------------------------------------------
void BackupClientContext::DoKeepAlive()
{
if (!mapConnection.get())
BackupProtocolCallable* pConnection(GetOpenConnection());
if (!pConnection)
{
return;
}
Expand All @@ -559,7 +567,7 @@ void BackupClientContext::DoKeepAlive()
}

BOX_TRACE("KeepAliveTime reached, sending keep-alive message");
mapConnection->QueryGetIsAlive();
pConnection->QueryGetIsAlive();

mKeepAliveTimer.Reset(mKeepAliveTime * MILLI_SEC_IN_SEC);
}
Expand Down
11 changes: 8 additions & 3 deletions bin/bbackupd/BackupClientContext.h
Expand Up @@ -54,11 +54,16 @@ class BackupClientContext : public DiffTimer
bool TcpNiceMode
);
virtual ~BackupClientContext();

private:
BackupClientContext(const BackupClientContext &);
public:

virtual BackupProtocolCallable &GetConnection();
public:
// GetConnection() will open a connection if none is currently open.
virtual BackupProtocolCallable& GetConnection();
// GetOpenConnection() will not open a connection, just return NULL if there is
// no connection already open.
virtual BackupProtocolCallable* GetOpenConnection() const;
void CloseAnyOpenConnection();
int GetTimeout() const;
BackupClientDeleteList &GetDeleteList();
Expand Down Expand Up @@ -167,7 +172,7 @@ class BackupClientContext : public DiffTimer
// Created: 04/19/2005
//
// --------------------------------------------------------------------------
void SetKeepAliveTime(int iSeconds);
virtual void SetKeepAliveTime(int iSeconds);

// --------------------------------------------------------------------------
//
Expand Down
8 changes: 4 additions & 4 deletions lib/backupstore/BackupStoreFileEncodeStream.h
Expand Up @@ -90,6 +90,9 @@ class BackupStoreFileEncodeStream : public IOStream
int64_t GetBytesToUpload() { return mBytesToUpload; }
int64_t GetTotalBytesSent() { return mTotalBytesSent; }

static void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut,
int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut);

private:
enum
{
Expand All @@ -98,15 +101,12 @@ class BackupStoreFileEncodeStream : public IOStream
Status_BlockListing = 2,
Status_Finished = 3
};

private:

void EncodeCurrentBlock();
void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut, int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut);
void SkipPreviousBlocksInInstruction();
void SetForInstruction();
void StoreBlockIndexEntry(int64_t WncSizeOrBlkIndex, int32_t ClearSize, uint32_t WeakChecksum, uint8_t *pStrongChecksum);

private:
Recipe *mpRecipe;
IOStream *mpFile; // source file
CollectInBufferStream mData; // buffer for header and index entries
Expand Down
8 changes: 6 additions & 2 deletions test/backupstorepatch/testbackupstorepatch.cpp
Expand Up @@ -504,9 +504,13 @@ int test(int argc, const char *argv[])
storeRootDir, discSet,
filenameOut,
false /* don't bother ensuring the directory exists */);
TEST_EQUAL(RaidFileUtil::NoFile,
std::ostringstream msg;
msg << "Unreferenced object " <<
test_files[f].IDOnServer <<
" was not deleted by housekeeping";
TEST_EQUAL_LINE(RaidFileUtil::NoFile,
RaidFileUtil::RaidFileExists(
rfd, filenameOut));
rfd, filenameOut), msg.str());
}
else
{
Expand Down

0 comments on commit 9774ed7

Please sign in to comment.