summaryrefslogtreecommitdiff
path: root/lib/server/makeprotocol.pl.in
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 /lib/server/makeprotocol.pl.in
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 'lib/server/makeprotocol.pl.in')
-rwxr-xr-xlib/server/makeprotocol.pl.in13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/server/makeprotocol.pl.in b/lib/server/makeprotocol.pl.in
index 35814d1d..00dc58d4 100755
--- a/lib/server/makeprotocol.pl.in
+++ b/lib/server/makeprotocol.pl.in
@@ -158,7 +158,9 @@ print CPP <<__E;
#include <sstream>
#include "$filename_base.h"
-#include "IOStream.h"
+#include "CollectInBufferStream.h"
+#include "SocketStream.h"
+#include "MemBlockStream.h"
__E
print H <<__E;
@@ -179,8 +181,7 @@ print H <<__E;
#include "ServerException.h"
class IOStream;
-
-
+class SocketStream;
__E
# extra headers
@@ -741,7 +742,7 @@ __E
else
{
print H <<__E;
- $server_or_client_class(IOStream &rStream);
+ $server_or_client_class(std::auto_ptr<SocketStream> apConn);
std::auto_ptr<$message_base_class> Receive();
void Send(const $message_base_class &rObject);
__E
@@ -885,8 +886,8 @@ __E
else
{
print CPP <<__E;
-$server_or_client_class\::$server_or_client_class(IOStream &rStream)
-: Protocol(rStream)
+$server_or_client_class\::$server_or_client_class(std::auto_ptr<SocketStream> apConn)
+: Protocol(apConn)
{ }
__E
}