Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
2a5fb6cb
Commit
2a5fb6cb
authored
Jan 31, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: ipc_listener_t data members not conforming to naming style
Solution: add underscore prefix
parent
7e735877
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
50 deletions
+50
-50
ipc_listener.cpp
src/ipc_listener.cpp
+43
-43
ipc_listener.hpp
src/ipc_listener.hpp
+7
-7
No files found.
src/ipc_listener.cpp
View file @
2a5fb6cb
...
@@ -134,28 +134,28 @@ zmq::ipc_listener_t::ipc_listener_t (io_thread_t *io_thread_,
...
@@ -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 ()
...
@@ -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 ()
...
@@ -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_)
...
@@ -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_)
...
@@ -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_)
...
@@ -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:
...
@@ -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 ()
...
@@ -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
...
...
src/ipc_listener.hpp
View file @
2a5fb6cb
...
@@ -85,26 +85,26 @@ class ipc_listener_t : public own_t, public io_object_t
...
@@ -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
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment