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
bed3b0cf
Commit
bed3b0cf
authored
Jan 31, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: tipc_listener_t data members not conforming to naming style
Solution: add underscore prefix
parent
2a5fb6cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
39 deletions
+38
-39
tipc_listener.cpp
src/tipc_listener.cpp
+33
-33
tipc_listener.hpp
src/tipc_listener.hpp
+5
-6
No files found.
src/tipc_listener.cpp
View file @
bed3b0cf
...
...
@@ -61,26 +61,26 @@ zmq::tipc_listener_t::tipc_listener_t (io_thread_t *io_thread_,
const
options_t
&
options_
)
:
own_t
(
io_thread_
,
options_
),
io_object_t
(
io_thread_
),
s
(
retired_fd
),
socket
(
socket_
)
_
s
(
retired_fd
),
_
socket
(
socket_
)
{
}
zmq
::
tipc_listener_t
::~
tipc_listener_t
()
{
zmq_assert
(
s
==
retired_fd
);
zmq_assert
(
_
s
==
retired_fd
);
}
void
zmq
::
tipc_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
::
tipc_listener_t
::
process_term
(
int
linger_
)
{
rm_fd
(
handle
);
rm_fd
(
_
handle
);
close
();
own_t
::
process_term
(
linger_
);
}
...
...
@@ -92,13 +92,13 @@ void zmq::tipc_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
...
...
@@ -108,12 +108,12 @@ void zmq::tipc_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
::
tipc_listener_t
::
get_address
(
std
::
string
&
addr_
)
...
...
@@ -122,9 +122,9 @@ int zmq::tipc_listener_t::get_address (std::string &addr_)
socklen_t
sl
=
sizeof
(
ss
);
#ifdef ZMQ_HAVE_VXWORKS
int
rc
=
getsockname
(
s
,
(
sockaddr
*
)
&
ss
,
(
int
*
)
&
sl
);
int
rc
=
getsockname
(
_
s
,
(
sockaddr
*
)
&
ss
,
(
int
*
)
&
sl
);
#else
int
rc
=
getsockname
(
s
,
(
sockaddr
*
)
&
ss
,
&
sl
);
int
rc
=
getsockname
(
_
s
,
(
sockaddr
*
)
&
ss
,
&
sl
);
#endif
if
(
rc
!=
0
)
{
addr_
.
clear
();
...
...
@@ -138,57 +138,57 @@ int zmq::tipc_listener_t::get_address (std::string &addr_)
int
zmq
::
tipc_listener_t
::
set_address
(
const
char
*
addr_
)
{
// Convert str to address struct
int
rc
=
address
.
resolve
(
addr_
);
int
rc
=
_
address
.
resolve
(
addr_
);
if
(
rc
!=
0
)
return
-
1
;
// Cannot bind non-random Port Identity
struct
sockaddr_tipc
*
a
=
(
sockaddr_tipc
*
)
address
.
addr
();
if
(
!
address
.
is_random
()
&&
a
->
addrtype
==
TIPC_ADDR_ID
)
{
struct
sockaddr_tipc
*
a
=
(
sockaddr_tipc
*
)
_
address
.
addr
();
if
(
!
_
address
.
is_random
()
&&
a
->
addrtype
==
TIPC_ADDR_ID
)
{
errno
=
EINVAL
;
return
-
1
;
}
// Create a listening socket.
s
=
open_socket
(
AF_TIPC
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
_
s
=
open_socket
(
AF_TIPC
,
SOCK_STREAM
,
0
);
if
(
_
s
==
-
1
)
return
-
1
;
// If random Port Identity, update address object to reflect the assigned address
if
(
address
.
is_random
())
{
if
(
_
address
.
is_random
())
{
struct
sockaddr_storage
ss
;
#ifdef ZMQ_HAVE_VXWORKS
int
sl
=
sizeof
(
ss
);
#else
socklen_t
sl
=
sizeof
(
ss
);
#endif
int
rc
=
getsockname
(
s
,
(
sockaddr
*
)
&
ss
,
&
sl
);
int
rc
=
getsockname
(
_
s
,
(
sockaddr
*
)
&
ss
,
&
sl
);
if
(
rc
!=
0
)
goto
error
;
address
=
tipc_address_t
((
struct
sockaddr
*
)
&
ss
,
sl
);
_
address
=
tipc_address_t
((
struct
sockaddr
*
)
&
ss
,
sl
);
}
address
.
to_string
(
endpoint
);
_address
.
to_string
(
_
endpoint
);
// Bind the socket to tipc name
if
(
address
.
is_service
())
{
if
(
_
address
.
is_service
())
{
#ifdef ZMQ_HAVE_VXWORKS
rc
=
bind
(
s
,
(
sockaddr
*
)
address
.
addr
(),
address
.
addrlen
());
rc
=
bind
(
_
s
,
(
sockaddr
*
)
address
.
addr
(),
address
.
addrlen
());
#else
rc
=
bind
(
s
,
address
.
addr
(),
address
.
addrlen
());
rc
=
bind
(
_s
,
_address
.
addr
(),
_
address
.
addrlen
());
#endif
if
(
rc
!=
0
)
goto
error
;
}
// Listen for incoming connections.
rc
=
listen
(
s
,
options
.
backlog
);
rc
=
listen
(
_
s
,
options
.
backlog
);
if
(
rc
!=
0
)
goto
error
;
socket
->
event_listening
(
endpoint
,
s
);
_socket
->
event_listening
(
_endpoint
,
_
s
);
return
0
;
error
:
...
...
@@ -200,11 +200,11 @@ error:
void
zmq
::
tipc_listener_t
::
close
()
{
zmq_assert
(
s
!=
retired_fd
);
int
rc
=
::
close
(
s
);
zmq_assert
(
_
s
!=
retired_fd
);
int
rc
=
::
close
(
_
s
);
errno_assert
(
rc
==
0
);
s
=
retired_fd
;
socket
->
event_closed
(
endpoint
,
s
);
_
s
=
retired_fd
;
_socket
->
event_closed
(
_endpoint
,
_
s
);
}
zmq
::
fd_t
zmq
::
tipc_listener_t
::
accept
()
...
...
@@ -215,11 +215,11 @@ zmq::fd_t zmq::tipc_listener_t::accept ()
struct
sockaddr_storage
ss
=
{};
socklen_t
ss_len
=
sizeof
(
ss
);
zmq_assert
(
s
!=
retired_fd
);
zmq_assert
(
_
s
!=
retired_fd
);
#ifdef ZMQ_HAVE_VXWORKS
fd_t
sock
=
::
accept
(
s
,
(
struct
sockaddr
*
)
&
ss
,
(
int
*
)
&
ss_len
);
fd_t
sock
=
::
accept
(
_
s
,
(
struct
sockaddr
*
)
&
ss
,
(
int
*
)
&
ss_len
);
#else
fd_t
sock
=
::
accept
(
s
,
(
struct
sockaddr
*
)
&
ss
,
&
ss_len
);
fd_t
sock
=
::
accept
(
_
s
,
(
struct
sockaddr
*
)
&
ss
,
&
ss_len
);
#endif
if
(
sock
==
-
1
)
{
errno_assert
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
...
...
src/tipc_listener.hpp
View file @
bed3b0cf
...
...
@@ -78,20 +78,19 @@ class tipc_listener_t : public own_t, public io_object_t
fd_t
accept
();
// Address to listen on
tipc_address_t
address
;
tipc_address_t
_
address
;
// 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
;
tipc_listener_t
(
const
tipc_listener_t
&
);
const
tipc_listener_t
&
operator
=
(
const
tipc_listener_t
&
);
...
...
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