mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-11 00:16:11 +00:00
Problem: ipc_listener_t data members not conforming to naming style
Solution: add underscore prefix
This commit is contained in:
parent
7e73587741
commit
2a5fb6cb8e
@ -134,28 +134,28 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_,
|
|||||||
const options_t &options_) :
|
const options_t &options_) :
|
||||||
own_t (io_thread_, options_),
|
own_t (io_thread_, options_),
|
||||||
io_object_t (io_thread_),
|
io_object_t (io_thread_),
|
||||||
has_file (false),
|
_has_file (false),
|
||||||
s (retired_fd),
|
_s (retired_fd),
|
||||||
handle (static_cast<handle_t> (NULL)),
|
_handle (static_cast<handle_t> (NULL)),
|
||||||
socket (socket_)
|
_socket (socket_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq::ipc_listener_t::~ipc_listener_t ()
|
zmq::ipc_listener_t::~ipc_listener_t ()
|
||||||
{
|
{
|
||||||
zmq_assert (s == retired_fd);
|
zmq_assert (_s == retired_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::ipc_listener_t::process_plug ()
|
void zmq::ipc_listener_t::process_plug ()
|
||||||
{
|
{
|
||||||
// Start polling for incoming connections.
|
// Start polling for incoming connections.
|
||||||
handle = add_fd (s);
|
_handle = add_fd (_s);
|
||||||
set_pollin (handle);
|
set_pollin (_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::ipc_listener_t::process_term (int linger_)
|
void zmq::ipc_listener_t::process_term (int linger_)
|
||||||
{
|
{
|
||||||
rm_fd (handle);
|
rm_fd (_handle);
|
||||||
close ();
|
close ();
|
||||||
own_t::process_term (linger_);
|
own_t::process_term (linger_);
|
||||||
}
|
}
|
||||||
@ -167,13 +167,13 @@ void zmq::ipc_listener_t::in_event ()
|
|||||||
// If connection was reset by the peer in the meantime, just ignore it.
|
// If connection was reset by the peer in the meantime, just ignore it.
|
||||||
// TODO: Handle specific errors like ENFILE/EMFILE etc.
|
// TODO: Handle specific errors like ENFILE/EMFILE etc.
|
||||||
if (fd == retired_fd) {
|
if (fd == retired_fd) {
|
||||||
socket->event_accept_failed (endpoint, zmq_errno ());
|
_socket->event_accept_failed (_endpoint, zmq_errno ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the engine object for this connection.
|
// Create the engine object for this connection.
|
||||||
stream_engine_t *engine =
|
stream_engine_t *engine =
|
||||||
new (std::nothrow) stream_engine_t (fd, options, endpoint);
|
new (std::nothrow) stream_engine_t (fd, options, _endpoint);
|
||||||
alloc_assert (engine);
|
alloc_assert (engine);
|
||||||
|
|
||||||
// Choose I/O thread to run connecter in. Given that we are already
|
// Choose I/O thread to run connecter in. Given that we are already
|
||||||
@ -183,12 +183,12 @@ void zmq::ipc_listener_t::in_event ()
|
|||||||
|
|
||||||
// Create and launch a session object.
|
// Create and launch a session object.
|
||||||
session_base_t *session =
|
session_base_t *session =
|
||||||
session_base_t::create (io_thread, false, socket, options, NULL);
|
session_base_t::create (io_thread, false, _socket, options, NULL);
|
||||||
errno_assert (session);
|
errno_assert (session);
|
||||||
session->inc_seqnum ();
|
session->inc_seqnum ();
|
||||||
launch_child (session);
|
launch_child (session);
|
||||||
send_attach (session, engine, false);
|
send_attach (session, engine, false);
|
||||||
socket->event_accepted (endpoint, fd);
|
_socket->event_accepted (_endpoint, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::ipc_listener_t::get_address (std::string &addr_)
|
int zmq::ipc_listener_t::get_address (std::string &addr_)
|
||||||
@ -199,7 +199,7 @@ int zmq::ipc_listener_t::get_address (std::string &addr_)
|
|||||||
#else
|
#else
|
||||||
socklen_t sl = sizeof (ss);
|
socklen_t sl = sizeof (ss);
|
||||||
#endif
|
#endif
|
||||||
int rc = getsockname (s, reinterpret_cast<sockaddr *> (&ss), &sl);
|
int rc = getsockname (_s, reinterpret_cast<sockaddr *> (&ss), &sl);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
addr_.clear ();
|
addr_.clear ();
|
||||||
return rc;
|
return rc;
|
||||||
@ -216,7 +216,7 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
|
|
||||||
// Allow wildcard file
|
// Allow wildcard file
|
||||||
if (options.use_fd == -1 && addr[0] == '*') {
|
if (options.use_fd == -1 && addr[0] == '*') {
|
||||||
if (create_wildcard_address (tmp_socket_dirname, addr) < 0) {
|
if (create_wildcard_address (_tmp_socket_dirname, addr) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,56 +229,56 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
if (options.use_fd == -1) {
|
if (options.use_fd == -1) {
|
||||||
::unlink (addr.c_str ());
|
::unlink (addr.c_str ());
|
||||||
}
|
}
|
||||||
filename.clear ();
|
_filename.clear ();
|
||||||
|
|
||||||
// Initialise the address structure.
|
// Initialise the address structure.
|
||||||
ipc_address_t address;
|
ipc_address_t address;
|
||||||
int rc = address.resolve (addr.c_str ());
|
int rc = address.resolve (addr.c_str ());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
if (!tmp_socket_dirname.empty ()) {
|
if (!_tmp_socket_dirname.empty ()) {
|
||||||
// We need to preserve errno to return to the user
|
// We need to preserve errno to return to the user
|
||||||
int tmp_errno = errno;
|
int tmp_errno = errno;
|
||||||
::rmdir (tmp_socket_dirname.c_str ());
|
::rmdir (_tmp_socket_dirname.c_str ());
|
||||||
tmp_socket_dirname.clear ();
|
_tmp_socket_dirname.clear ();
|
||||||
errno = tmp_errno;
|
errno = tmp_errno;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
address.to_string (endpoint);
|
address.to_string (_endpoint);
|
||||||
|
|
||||||
if (options.use_fd != -1) {
|
if (options.use_fd != -1) {
|
||||||
s = options.use_fd;
|
_s = options.use_fd;
|
||||||
} else {
|
} else {
|
||||||
// Create a listening socket.
|
// Create a listening socket.
|
||||||
s = open_socket (AF_UNIX, SOCK_STREAM, 0);
|
_s = open_socket (AF_UNIX, SOCK_STREAM, 0);
|
||||||
if (s == -1) {
|
if (_s == -1) {
|
||||||
if (!tmp_socket_dirname.empty ()) {
|
if (!_tmp_socket_dirname.empty ()) {
|
||||||
// We need to preserve errno to return to the user
|
// We need to preserve errno to return to the user
|
||||||
int tmp_errno = errno;
|
int tmp_errno = errno;
|
||||||
::rmdir (tmp_socket_dirname.c_str ());
|
::rmdir (_tmp_socket_dirname.c_str ());
|
||||||
tmp_socket_dirname.clear ();
|
_tmp_socket_dirname.clear ();
|
||||||
errno = tmp_errno;
|
errno = tmp_errno;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the socket to the file path.
|
// Bind the socket to the file path.
|
||||||
rc = bind (s, const_cast<sockaddr *> (address.addr ()),
|
rc = bind (_s, const_cast<sockaddr *> (address.addr ()),
|
||||||
address.addrlen ());
|
address.addrlen ());
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
// Listen for incoming connections.
|
// Listen for incoming connections.
|
||||||
rc = listen (s, options.backlog);
|
rc = listen (_s, options.backlog);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = ZMQ_MOVE (addr);
|
_filename = ZMQ_MOVE (addr);
|
||||||
has_file = true;
|
_has_file = true;
|
||||||
|
|
||||||
socket->event_listening (endpoint, s);
|
_socket->event_listening (_endpoint, _s);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -290,28 +290,28 @@ error:
|
|||||||
|
|
||||||
int zmq::ipc_listener_t::close ()
|
int zmq::ipc_listener_t::close ()
|
||||||
{
|
{
|
||||||
zmq_assert (s != retired_fd);
|
zmq_assert (_s != retired_fd);
|
||||||
int fd_for_event = s;
|
int fd_for_event = _s;
|
||||||
int rc = ::close (s);
|
int rc = ::close (_s);
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
s = retired_fd;
|
_s = retired_fd;
|
||||||
|
|
||||||
if (has_file && options.use_fd == -1) {
|
if (_has_file && options.use_fd == -1) {
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
if (rc == 0 && !tmp_socket_dirname.empty ()) {
|
if (rc == 0 && !_tmp_socket_dirname.empty ()) {
|
||||||
rc = ::rmdir (tmp_socket_dirname.c_str ());
|
rc = ::rmdir (_tmp_socket_dirname.c_str ());
|
||||||
tmp_socket_dirname.clear ();
|
_tmp_socket_dirname.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
socket->event_close_failed (endpoint, zmq_errno ());
|
_socket->event_close_failed (_endpoint, zmq_errno ());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket->event_closed (endpoint, fd_for_event);
|
_socket->event_closed (_endpoint, fd_for_event);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,11 +389,11 @@ zmq::fd_t zmq::ipc_listener_t::accept ()
|
|||||||
// Accept one connection and deal with different failure modes.
|
// Accept one connection and deal with different failure modes.
|
||||||
// The situation where connection cannot be accepted due to insufficient
|
// The situation where connection cannot be accepted due to insufficient
|
||||||
// resources is considered valid and treated by ignoring the connection.
|
// resources is considered valid and treated by ignoring the connection.
|
||||||
zmq_assert (s != retired_fd);
|
zmq_assert (_s != retired_fd);
|
||||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
||||||
fd_t sock = ::accept4 (s, NULL, NULL, SOCK_CLOEXEC);
|
fd_t sock = ::accept4 (_s, NULL, NULL, SOCK_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
fd_t sock = ::accept (s, NULL, NULL);
|
fd_t sock = ::accept (_s, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
if (sock == -1) {
|
if (sock == -1) {
|
||||||
errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR
|
errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR
|
||||||
|
@ -85,26 +85,26 @@ class ipc_listener_t : public own_t, public io_object_t
|
|||||||
fd_t accept ();
|
fd_t accept ();
|
||||||
|
|
||||||
// True, if the underlying file for UNIX domain socket exists.
|
// True, if the underlying file for UNIX domain socket exists.
|
||||||
bool has_file;
|
bool _has_file;
|
||||||
|
|
||||||
// Name of the temporary directory (if any) that has the
|
// Name of the temporary directory (if any) that has the
|
||||||
// the UNIX domain socket
|
// the UNIX domain socket
|
||||||
std::string tmp_socket_dirname;
|
std::string _tmp_socket_dirname;
|
||||||
|
|
||||||
// Name of the file associated with the UNIX domain address.
|
// Name of the file associated with the UNIX domain address.
|
||||||
std::string filename;
|
std::string _filename;
|
||||||
|
|
||||||
// Underlying socket.
|
// Underlying socket.
|
||||||
fd_t s;
|
fd_t _s;
|
||||||
|
|
||||||
// Handle corresponding to the listening socket.
|
// Handle corresponding to the listening socket.
|
||||||
handle_t handle;
|
handle_t _handle;
|
||||||
|
|
||||||
// Socket the listener belongs to.
|
// Socket the listener belongs to.
|
||||||
zmq::socket_base_t *socket;
|
zmq::socket_base_t *_socket;
|
||||||
|
|
||||||
// String representation of endpoint to bind to
|
// String representation of endpoint to bind to
|
||||||
std::string endpoint;
|
std::string _endpoint;
|
||||||
|
|
||||||
// Acceptable temporary directory environment variables
|
// Acceptable temporary directory environment variables
|
||||||
static const char *tmp_env_vars[];
|
static const char *tmp_env_vars[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user