Skip to content

Commit 1d6c9ed

Browse files
RK-BFXklemens-morgenstern
authored andcommitted
Fix conflicting pipe name in independent plug-in DLLs
Include numerical representation of local static variable's address into the pipe name to discriminate Boost.Process instances in independent DLLs. Fixes #476 Also (auto-)remove excessive concurrent empty lines.
1 parent a941c8e commit 1d6c9ed

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

include/boost/process/v1/detail/windows/async_pipe.hpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ inline std::string make_pipe_name()
3131
static std::atomic_size_t cnt{0};
3232
name += std::to_string(pid);
3333
name += "_";
34+
name += std::to_string(intptr_t(&cnt)); // to unclash Boost instances in plug-in DLLs
35+
name += "_";
3436
name += std::to_string(cnt++);
3537

3638
return name;
@@ -60,8 +62,6 @@ class async_pipe
6062
async_pipe(boost::asio::io_context & ios_source, boost::asio::io_context & ios_sink, const std::string & name)
6163
: async_pipe(ios_source, ios_sink, name, false) {}
6264

63-
64-
6565
inline async_pipe(const async_pipe& rhs);
6666
async_pipe(async_pipe&& rhs) : _source(std::move(rhs._source)), _sink(std::move(rhs._sink))
6767
{
@@ -153,7 +153,6 @@ class async_pipe
153153
return _sink.write_some(buffers);
154154
}
155155

156-
157156
template<typename MutableBufferSequence>
158157
std::size_t read_some(const MutableBufferSequence & buffers, boost::system::error_code & ec) noexcept
159158
{
@@ -281,7 +280,6 @@ async_pipe::async_pipe(const async_pipe& p) :
281280
_sink. assign(sink);
282281
}
283282

284-
285283
async_pipe::async_pipe(boost::asio::io_context & ios_source,
286284
boost::asio::io_context & ios_sink,
287285
const std::string & name, bool private_) : _source(ios_source), _sink(ios_sink)
@@ -298,7 +296,6 @@ async_pipe::async_pipe(boost::asio::io_context & ios_source,
298296
| FILE_FLAG_OVERLAPPED_, //write flag
299297
0, private_ ? 1 : ::boost::winapi::PIPE_UNLIMITED_INSTANCES_, 8192, 8192, 0, nullptr);
300298

301-
302299
if (source == boost::winapi::INVALID_HANDLE_VALUE_)
303300
::boost::process::v1::detail::throw_last_error("create_named_pipe(" + name + ") failed");
304301

0 commit comments

Comments
 (0)