diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-03-02 08:59:39 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-03-02 08:59:39 +0000 |
commit | c30a30907d26fb25f449fb3f03274418f935b0a7 (patch) | |
tree | ef9b22698b5ca5e035bfe234722a8854e4b357c5 /test/backupstore | |
parent | b88db70703097ae8e5894e6dd5af2c5b672799a9 (diff) |
Always flush any incoming stream on server side.
Otherwise the protocol might be broken and can't be used any more, even if
we made an effort to return an Error reply instead of throwing an exception.
This used to not be a problem because an Error reply would terminate the
connection anyway, but it no longer does. So if the client also didn't
terminate, but tried to handle the exception and keep using the connection,
then it might find that its next command fails because the protocol is broken.
Diffstat (limited to 'test/backupstore')
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 300a666b..8b185f1e 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -45,6 +45,7 @@ #include "StoreTestUtils.h" #include "TLSContext.h" #include "Test.h" +#include "ZeroStream.h" #include "MemLeakFindOn.h" @@ -1077,6 +1078,18 @@ bool test_server_housekeeping() TEST_THAT(check_num_files(0, 0, 0, 1)); TEST_THAT(check_num_blocks(protocol, 0, 0, 0, root_dir_blocks, root_dir_blocks)); + // Used to not consume the stream + std::auto_ptr<IOStream> upload(new ZeroStream(1000)); + TEST_COMMAND_RETURNS_ERROR(protocol.QueryStoreFile( + BACKUPSTORE_ROOT_DIRECTORY_ID, + 0, + 0, /* use for attr hash too */ + 99999, /* diff from ID */ + uploads[0].name, + upload), + Err_DiffFromFileDoesNotExist); + // TODO FIXME replace all other TEST_CHECK_THROWS with TEST_COMMAND_RETURNS_ERROR + // TODO FIXME These tests should not be here, but in // test_server_commands. But make sure you use a network protocol, // not a local one, when you move them. |