transport/unix: Fixing segfault due to errorneous creation of multiple UnixTransport::Impl instances
The bug showed itself when multiple expressInterest's were issued before
running processEvents.
Change-Id: I7e60d0ae625777e06471aca00707d7b88e68a5c8
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
index 5ee6a61..5aca79e 100644
--- a/src/transport/unix-transport.cpp
+++ b/src/transport/unix-transport.cpp
@@ -246,9 +246,11 @@
UnixTransport::connect(boost::asio::io_service &ioService,
const ReceiveCallback &receiveCallback)
{
- Transport::connect(ioService, receiveCallback);
+ if (!static_cast<bool>(impl_)) {
+ Transport::connect(ioService, receiveCallback);
- impl_ = std::auto_ptr<UnixTransport::Impl> (new UnixTransport::Impl(*this));
+ impl_ = ptr_lib::make_shared<UnixTransport::Impl> (ptr_lib::ref(*this));
+ }
impl_->connect();
}