mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +08:00
Fixed naming for filter parameter, removed unnecessary temporary variable, fixed naming of local variable
This commit is contained in:
parent
a1b6268c83
commit
b102e30419
@ -115,7 +115,7 @@ int zmq::ipc_listener_t::create_wildcard_address (std::string &path_,
|
|||||||
}
|
}
|
||||||
|
|
||||||
path_.assign (&buffer[0]);
|
path_.assign (&buffer[0]);
|
||||||
file_.assign (path_ + "/socket");
|
file_ = path_ + "/socket";
|
||||||
#else
|
#else
|
||||||
// Silence -Wunused-parameter. #pragma and __attribute__((unused)) are not
|
// Silence -Wunused-parameter. #pragma and __attribute__((unused)) are not
|
||||||
// very portable unfortunately...
|
// very portable unfortunately...
|
||||||
@ -138,7 +138,7 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_,
|
|||||||
io_object_t (io_thread_),
|
io_object_t (io_thread_),
|
||||||
has_file (false),
|
has_file (false),
|
||||||
s (retired_fd),
|
s (retired_fd),
|
||||||
handle ((handle_t) NULL),
|
handle (static_cast<handle_t> (NULL)),
|
||||||
socket (socket_)
|
socket (socket_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -239,10 +239,10 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
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 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 = errno_;
|
errno = tmp_errno;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -257,10 +257,10 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
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 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 = errno_;
|
errno = tmp_errno;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename.assign (addr.c_str ());
|
filename = ZMQ_MOVE (addr);
|
||||||
has_file = true;
|
has_file = true;
|
||||||
|
|
||||||
socket->event_listening (endpoint, s);
|
socket->event_listening (endpoint, s);
|
||||||
@ -319,7 +319,7 @@ int zmq::ipc_listener_t::close ()
|
|||||||
|
|
||||||
#if defined ZMQ_HAVE_SO_PEERCRED
|
#if defined ZMQ_HAVE_SO_PEERCRED
|
||||||
|
|
||||||
bool zmq::ipc_listener_t::filter (fd_t sock)
|
bool zmq::ipc_listener_t::filter (fd_t sock_)
|
||||||
{
|
{
|
||||||
if (options.ipc_uid_accept_filters.empty ()
|
if (options.ipc_uid_accept_filters.empty ()
|
||||||
&& options.ipc_pid_accept_filters.empty ()
|
&& options.ipc_pid_accept_filters.empty ()
|
||||||
@ -329,7 +329,7 @@ bool zmq::ipc_listener_t::filter (fd_t sock)
|
|||||||
struct ucred cred;
|
struct ucred cred;
|
||||||
socklen_t size = sizeof (cred);
|
socklen_t size = sizeof (cred);
|
||||||
|
|
||||||
if (getsockopt (sock, SOL_SOCKET, SO_PEERCRED, &cred, &size))
|
if (getsockopt (sock_, SOL_SOCKET, SO_PEERCRED, &cred, &size))
|
||||||
return false;
|
return false;
|
||||||
if (options.ipc_uid_accept_filters.find (cred.uid)
|
if (options.ipc_uid_accept_filters.find (cred.uid)
|
||||||
!= options.ipc_uid_accept_filters.end ()
|
!= options.ipc_uid_accept_filters.end ()
|
||||||
@ -359,7 +359,7 @@ bool zmq::ipc_listener_t::filter (fd_t sock)
|
|||||||
|
|
||||||
#elif defined ZMQ_HAVE_LOCAL_PEERCRED
|
#elif defined ZMQ_HAVE_LOCAL_PEERCRED
|
||||||
|
|
||||||
bool zmq::ipc_listener_t::filter (fd_t sock)
|
bool zmq::ipc_listener_t::filter (fd_t sock_)
|
||||||
{
|
{
|
||||||
if (options.ipc_uid_accept_filters.empty ()
|
if (options.ipc_uid_accept_filters.empty ()
|
||||||
&& options.ipc_gid_accept_filters.empty ())
|
&& options.ipc_gid_accept_filters.empty ())
|
||||||
@ -368,7 +368,7 @@ bool zmq::ipc_listener_t::filter (fd_t sock)
|
|||||||
struct xucred cred;
|
struct xucred cred;
|
||||||
socklen_t size = sizeof (cred);
|
socklen_t size = sizeof (cred);
|
||||||
|
|
||||||
if (getsockopt (sock, 0, LOCAL_PEERCRED, &cred, &size))
|
if (getsockopt (sock_, 0, LOCAL_PEERCRED, &cred, &size))
|
||||||
return false;
|
return false;
|
||||||
if (cred.cr_version != XUCRED_VERSION)
|
if (cred.cr_version != XUCRED_VERSION)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user