summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-03-02 08:59:39 +0000
committerChris Wilson <chris+github@qwirx.com>2014-03-02 08:59:39 +0000
commitc30a30907d26fb25f449fb3f03274418f935b0a7 (patch)
treeef9b22698b5ca5e035bfe234722a8854e4b357c5 /lib/common
parentb88db70703097ae8e5894e6dd5af2c5b672799a9 (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 'lib/common')
-rw-r--r--lib/common/SelfFlushingStream.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/common/SelfFlushingStream.h b/lib/common/SelfFlushingStream.h
index 36e9a4d3..6865ab96 100644
--- a/lib/common/SelfFlushingStream.h
+++ b/lib/common/SelfFlushingStream.h
@@ -33,6 +33,12 @@ public:
~SelfFlushingStream()
{
+ if(StreamDataLeft())
+ {
+ BOX_WARNING("Not all data was read from stream, "
+ "discarding the rest");
+ }
+
Flush();
}