mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 07:56:09 +00:00
Merge pull request #700 from hashstat/master
Add documentation on Linux ipc abstract namespace support and a bug fix.
This commit is contained in:
commit
283e52357c
1
.gitignore
vendored
1
.gitignore
vendored
@ -69,6 +69,7 @@ tests/test_inproc_connect
|
|||||||
tests/test_linger
|
tests/test_linger
|
||||||
tests/test_security_null
|
tests/test_security_null
|
||||||
tests/test_security_plain
|
tests/test_security_plain
|
||||||
|
tests/test_abstract_ipc
|
||||||
tests/test*.log
|
tests/test*.log
|
||||||
tests/test*.trs
|
tests/test*.trs
|
||||||
src/platform.hpp*
|
src/platform.hpp*
|
||||||
|
@ -48,6 +48,11 @@ NOTE: the endpoint pathname must be writable by the process. When the endpoint
|
|||||||
starts with '/', e.g., `ipc:///pathname`, this will be an _absolute_ pathname.
|
starts with '/', e.g., `ipc:///pathname`, this will be an _absolute_ pathname.
|
||||||
If the endpoint specifies a directory that does not exist, the bind shall fail.
|
If the endpoint specifies a directory that does not exist, the bind shall fail.
|
||||||
|
|
||||||
|
NOTE: on Linux only, when the endpoint pathname starts with `@`, the abstract
|
||||||
|
namespace shall be used. The abstract namespace is independent of the
|
||||||
|
filesystem and if a process attempts to bind an endpoint already bound by a
|
||||||
|
process, it will fail. See unix(7) for details.
|
||||||
|
|
||||||
Connecting a socket
|
Connecting a socket
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
When connecting a 'socket' to a peer address using _zmq_connect()_ with the
|
When connecting a 'socket' to a peer address using _zmq_connect()_ with the
|
||||||
|
@ -51,11 +51,18 @@ int zmq::ipc_address_t::resolve (const char *path_)
|
|||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#if defined ZMQ_HAVE_LINUX
|
||||||
|
if (path_[0] == '@' && !path_[1]) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
address.sun_family = AF_UNIX;
|
address.sun_family = AF_UNIX;
|
||||||
strcpy (address.sun_path, path_);
|
strcpy (address.sun_path, path_);
|
||||||
#if defined ZMQ_HAVE_LINUX
|
#if defined ZMQ_HAVE_LINUX
|
||||||
if (*path_ == '@')
|
/* Abstract sockets on Linux start with '\0' */
|
||||||
|
if (path_[0] == '@')
|
||||||
*address.sun_path = '\0';
|
*address.sun_path = '\0';
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -73,10 +80,10 @@ int zmq::ipc_address_t::to_string (std::string &addr_)
|
|||||||
s << "ipc://" << address.sun_path;
|
s << "ipc://" << address.sun_path;
|
||||||
#else
|
#else
|
||||||
s << "ipc://";
|
s << "ipc://";
|
||||||
if (*address.sun_path)
|
if (!address.sun_path[0] && address.sun_path[1])
|
||||||
s << address.sun_path;
|
|
||||||
else
|
|
||||||
s << "@" << address.sun_path + 1;
|
s << "@" << address.sun_path + 1;
|
||||||
|
else
|
||||||
|
s << address.sun_path;
|
||||||
#endif
|
#endif
|
||||||
addr_ = s.str ();
|
addr_ = s.str ();
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,6 +96,10 @@ const sockaddr *zmq::ipc_address_t::addr () const
|
|||||||
|
|
||||||
socklen_t zmq::ipc_address_t::addrlen () const
|
socklen_t zmq::ipc_address_t::addrlen () const
|
||||||
{
|
{
|
||||||
|
#if defined ZMQ_HAVE_LINUX
|
||||||
|
if (!address.sun_path[0] && address.sun_path[1])
|
||||||
|
return (socklen_t) strlen(address.sun_path + 1) + sizeof (sa_family_t) + 1;
|
||||||
|
#endif
|
||||||
return (socklen_t) sizeof (address);
|
return (socklen_t) sizeof (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user