Commit 31cdbd2a authored by Brandon Carpenter's avatar Brandon Carpenter

Add abstract namespace support for IPC sockets on Linux.

Converts an initial strudel or "at sign" (@) in the Unix socket path to
a NULL character ('\0') indicating that the socket uses the abstract
namespace instead of the filesystem namespace.  For instance, binding a
socket to 'ipc://@/tmp/tester' will not create a file associated with
the socket whereas binding to 'ipc:///tmp/tester' will create the file
/tmp/tester.  See issue 567 for more information.
parent 23e58e30
......@@ -20,6 +20,7 @@ Ben Gray <ben@benjamg.com>
Bernd Prager <bernd@prager.ws>
Bernd Melchers <melchers@ZEDAT.FU-Berlin.DE>
Bob Beaty <rbeaty@peak6.com>
Brandon Carpenter <hashstat@yahoo.com>
Brian Buchanan <bwb@holo.org>
Brett Cameron <Brett.Cameron@hp.com>
Burak Arslan <burak-github@arskom.com.tr>
......
......@@ -54,6 +54,10 @@ int zmq::ipc_address_t::resolve (const char *path_)
address.sun_family = AF_UNIX;
strcpy (address.sun_path, path_);
#if defined ZMQ_HAVE_LINUX
if (*path_ == '@')
*address.sun_path = '\0';
#endif
return 0;
}
......@@ -65,7 +69,15 @@ int zmq::ipc_address_t::to_string (std::string &addr_)
}
std::stringstream s;
#if !defined ZMQ_HAVE_LINUX
s << "ipc://" << address.sun_path;
#else
s << "ipc://";
if (*address.sun_path)
s << address.sun_path;
else
s << "@" << address.sun_path + 1;
#endif
addr_ = s.str ();
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment