Skip to content

Commit

Permalink
Add abstract namespace support for IPC sockets on Linux.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Brandon Carpenter authored and hintjens committed Oct 5, 2013
1 parent a570b18 commit 668f000
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Ben Gray <[email protected]>
Bernd Prager <[email protected]>
Bernd Melchers <[email protected]>
Bob Beaty <[email protected]>
Brandon Carpenter <[email protected]>
Brian Buchanan <[email protected]>
Brett Cameron <[email protected]>
Burak Arslan <[email protected]>
Expand Down
12 changes: 12 additions & 0 deletions src/ipc_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 668f000

Please sign in to comment.