mirror of
https://github.com/zeromq/libzmq.git
synced 2025-02-23 15:14:40 +01: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_) :
|
||||
own_t (io_thread_, options_),
|
||||
io_object_t (io_thread_),
|
||||
has_file (false),
|
||||
s (retired_fd),
|
||||
handle (static_cast<handle_t> (NULL)),
|
||||
socket (socket_)
|
||||
_has_file (false),
|
||||
_s (retired_fd),
|
||||
_handle (static_cast<handle_t> (NULL)),
|
||||
_socket (socket_)
|
||||
{
|
||||
}
|
||||
|
||||
zmq::ipc_listener_t::~ipc_listener_t ()
|
||||
{
|
||||
zmq_assert (s == retired_fd);
|
||||
zmq_assert (_s == retired_fd);
|
||||
}
|
||||
|
||||
void zmq::ipc_listener_t::process_plug ()
|
||||
{
|
||||
// Start polling for incoming connections.
|
||||
handle = add_fd (s);
|
||||
set_pollin (handle);
|
||||
_handle = add_fd (_s);
|
||||
set_pollin (_handle);
|
||||
}
|
||||
|
||||
void zmq::ipc_listener_t::process_term (int linger_)
|
||||
{
|
||||
rm_fd (handle);
|
||||
rm_fd (_handle);
|
||||
close ();
|
||||
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.
|
||||
// TODO: Handle specific errors like ENFILE/EMFILE etc.
|
||||
if (fd == retired_fd) {
|
||||
socket->event_accept_failed (endpoint, zmq_errno ());
|
||||
_socket->event_accept_failed (_endpoint, zmq_errno ());
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the engine object for this connection.
|
||||
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);
|
||||
|
||||
// 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.
|
||||
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);
|
||||
session->inc_seqnum ();
|
||||
launch_child (session);
|
||||
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_)
|
||||
@ -199,7 +199,7 @@ int zmq::ipc_listener_t::get_address (std::string &addr_)
|
||||
#else
|
||||
socklen_t sl = sizeof (ss);
|
||||
#endif
|
||||
int rc = getsockname (s, reinterpret_cast<sockaddr *> (&ss), &sl);
|
||||
int rc = getsockname (_s, reinterpret_cast<sockaddr *> (&ss), &sl);
|
||||
if (rc != 0) {
|
||||
addr_.clear ();
|
||||
return rc;
|
||||
@ -216,7 +216,7 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
||||
|
||||
// Allow wildcard file
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -229,56 +229,56 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
||||
if (options.use_fd == -1) {
|
||||
::unlink (addr.c_str ());
|
||||
}
|
||||
filename.clear ();
|
||||
_filename.clear ();
|
||||
|
||||
// Initialise the address structure.
|
||||
ipc_address_t address;
|
||||
int rc = address.resolve (addr.c_str ());
|
||||
if (rc != 0) {
|
||||
if (!tmp_socket_dirname.empty ()) {
|
||||
if (!_tmp_socket_dirname.empty ()) {
|
||||
// We need to preserve errno to return to the user
|
||||
int tmp_errno = errno;
|
||||
::rmdir (tmp_socket_dirname.c_str ());
|
||||
tmp_socket_dirname.clear ();
|
||||
::rmdir (_tmp_socket_dirname.c_str ());
|
||||
_tmp_socket_dirname.clear ();
|
||||
errno = tmp_errno;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
address.to_string (endpoint);
|
||||
address.to_string (_endpoint);
|
||||
|
||||
if (options.use_fd != -1) {
|
||||
s = options.use_fd;
|
||||
_s = options.use_fd;
|
||||
} else {
|
||||
// Create a listening socket.
|
||||
s = open_socket (AF_UNIX, SOCK_STREAM, 0);
|
||||
if (s == -1) {
|
||||
if (!tmp_socket_dirname.empty ()) {
|
||||
_s = open_socket (AF_UNIX, SOCK_STREAM, 0);
|
||||
if (_s == -1) {
|
||||
if (!_tmp_socket_dirname.empty ()) {
|
||||
// We need to preserve errno to return to the user
|
||||
int tmp_errno = errno;
|
||||
::rmdir (tmp_socket_dirname.c_str ());
|
||||
tmp_socket_dirname.clear ();
|
||||
::rmdir (_tmp_socket_dirname.c_str ());
|
||||
_tmp_socket_dirname.clear ();
|
||||
errno = tmp_errno;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 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 ());
|
||||
if (rc != 0)
|
||||
goto error;
|
||||
|
||||
// Listen for incoming connections.
|
||||
rc = listen (s, options.backlog);
|
||||
rc = listen (_s, options.backlog);
|
||||
if (rc != 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
filename = ZMQ_MOVE (addr);
|
||||
has_file = true;
|
||||
_filename = ZMQ_MOVE (addr);
|
||||
_has_file = true;
|
||||
|
||||
socket->event_listening (endpoint, s);
|
||||
_socket->event_listening (_endpoint, _s);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
@ -290,28 +290,28 @@ error:
|
||||
|
||||
int zmq::ipc_listener_t::close ()
|
||||
{
|
||||
zmq_assert (s != retired_fd);
|
||||
int fd_for_event = s;
|
||||
int rc = ::close (s);
|
||||
zmq_assert (_s != retired_fd);
|
||||
int fd_for_event = _s;
|
||||
int rc = ::close (_s);
|
||||
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;
|
||||
|
||||
if (rc == 0 && !tmp_socket_dirname.empty ()) {
|
||||
rc = ::rmdir (tmp_socket_dirname.c_str ());
|
||||
tmp_socket_dirname.clear ();
|
||||
if (rc == 0 && !_tmp_socket_dirname.empty ()) {
|
||||
rc = ::rmdir (_tmp_socket_dirname.c_str ());
|
||||
_tmp_socket_dirname.clear ();
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
socket->event_close_failed (endpoint, zmq_errno ());
|
||||
_socket->event_close_failed (_endpoint, zmq_errno ());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
socket->event_closed (endpoint, fd_for_event);
|
||||
_socket->event_closed (_endpoint, fd_for_event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -389,11 +389,11 @@ zmq::fd_t zmq::ipc_listener_t::accept ()
|
||||
// Accept one connection and deal with different failure modes.
|
||||
// The situation where connection cannot be accepted due to insufficient
|
||||
// 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
|
||||
fd_t sock = ::accept4 (s, NULL, NULL, SOCK_CLOEXEC);
|
||||
fd_t sock = ::accept4 (_s, NULL, NULL, SOCK_CLOEXEC);
|
||||
#else
|
||||
fd_t sock = ::accept (s, NULL, NULL);
|
||||
fd_t sock = ::accept (_s, NULL, NULL);
|
||||
#endif
|
||||
if (sock == -1) {
|
||||
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 ();
|
||||
|
||||
// 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
|
||||
// the UNIX domain socket
|
||||
std::string tmp_socket_dirname;
|
||||
std::string _tmp_socket_dirname;
|
||||
|
||||
// Name of the file associated with the UNIX domain address.
|
||||
std::string filename;
|
||||
std::string _filename;
|
||||
|
||||
// Underlying socket.
|
||||
fd_t s;
|
||||
fd_t _s;
|
||||
|
||||
// Handle corresponding to the listening socket.
|
||||
handle_t handle;
|
||||
handle_t _handle;
|
||||
|
||||
// Socket the listener belongs to.
|
||||
zmq::socket_base_t *socket;
|
||||
zmq::socket_base_t *_socket;
|
||||
|
||||
// String representation of endpoint to bind to
|
||||
std::string endpoint;
|
||||
std::string _endpoint;
|
||||
|
||||
// Acceptable temporary directory environment variables
|
||||
static const char *tmp_env_vars[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user