summaryrefslogtreecommitdiff
path: root/test/backupstorepatch
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-03-01 10:42:48 +0000
committerChris Wilson <chris+github@qwirx.com>2014-03-01 10:42:48 +0000
commit2b6ac135fa7071290289741c9e35747bb9f1012f (patch)
tree037507c43ac097fb2cd5850bbd57f25a553e20e8 /test/backupstorepatch
parent2ef0a9aa8cd3cd4dcfa0cd9d2014051832c52e8a (diff)
Make Protocol take control of the socket object passed in.
We pass a std::auto_ptr<SocketStream> to every Protocol subclass when we construct it, and it takes control of this object. This reduces the risk of: * accidentally reusing the same SocketStream for multiple Protocols (it happened to me in testbackupstore); * holding onto a reference to the SocketStream; * allowing a locally-scoped SocketStream to go out of scope and be released while still being referenced by a live Protocol.
Diffstat (limited to 'test/backupstorepatch')
-rw-r--r--test/backupstorepatch/testbackupstorepatch.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp
index 42594652..96b93308 100644
--- a/test/backupstorepatch/testbackupstorepatch.cpp
+++ b/test/backupstorepatch/testbackupstorepatch.cpp
@@ -345,12 +345,13 @@ int test(int argc, const char *argv[])
{
// Open a connection to the server
- SocketStreamTLS conn;
- conn.Open(context, Socket::TypeINET, "localhost",
+ SocketStreamTLS *pConn = new SocketStreamTLS;
+ std::auto_ptr<SocketStream> apConn(pConn);
+ pConn->Open(context, Socket::TypeINET, "localhost",
BOX_PORT_BBSTORED_TEST);
// Make a protocol
- BackupProtocolClient protocol(conn);
+ BackupProtocolClient protocol(apConn);
// Login
{
@@ -454,7 +455,6 @@ int test(int argc, const char *argv[])
// Finish the connection
protocol.QueryFinished();
- conn.Close();
}
// Fill in initial dependency information
@@ -528,10 +528,11 @@ int test(int argc, const char *argv[])
}
// Open a connection to the server (need to do this each time, otherwise housekeeping won't delete files)
- SocketStreamTLS conn;
- conn.Open(context, Socket::TypeINET, "localhost",
+ SocketStreamTLS *pConn = new SocketStreamTLS;
+ std::auto_ptr<SocketStream> apConn(pConn);
+ pConn->Open(context, Socket::TypeINET, "localhost",
BOX_PORT_BBSTORED_TEST);
- BackupProtocolClient protocol(conn);
+ BackupProtocolClient protocol(apConn);
{
std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
@@ -583,7 +584,6 @@ int test(int argc, const char *argv[])
// Close the connection
protocol.QueryFinished();
- conn.Close();
// Mark one of the elements as deleted
if(test_file_remove_order[deleteIndex] == -1)