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
c94ad648
Commit
c94ad648
authored
Jan 31, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: tipc_connector_t data members not conforming to naming conventions
Solution: add underscore prefix to data members
parent
58063a75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
64 deletions
+64
-64
tipc_connecter.cpp
src/tipc_connecter.cpp
+54
-54
tipc_connecter.hpp
src/tipc_connecter.hpp
+10
-10
No files found.
src/tipc_connecter.cpp
View file @
c94ad648
...
@@ -60,30 +60,30 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
...
@@ -60,30 +60,30 @@ zmq::tipc_connecter_t::tipc_connecter_t (class io_thread_t *io_thread_,
bool
delayed_start_
)
:
bool
delayed_start_
)
:
own_t
(
io_thread_
,
options_
),
own_t
(
io_thread_
,
options_
),
io_object_t
(
io_thread_
),
io_object_t
(
io_thread_
),
addr
(
addr_
),
_
addr
(
addr_
),
s
(
retired_fd
),
_
s
(
retired_fd
),
handle_valid
(
false
),
_
handle_valid
(
false
),
delayed_start
(
delayed_start_
),
_
delayed_start
(
delayed_start_
),
timer_started
(
false
),
_
timer_started
(
false
),
session
(
session_
),
_
session
(
session_
),
current_reconnect_ivl
(
options
.
reconnect_ivl
)
_
current_reconnect_ivl
(
options
.
reconnect_ivl
)
{
{
zmq_assert
(
addr
);
zmq_assert
(
_
addr
);
zmq_assert
(
addr
->
protocol
==
"tipc"
);
zmq_assert
(
_
addr
->
protocol
==
"tipc"
);
addr
->
to_string
(
endpoint
);
_addr
->
to_string
(
_
endpoint
);
socket
=
session
->
get_socket
();
_socket
=
_
session
->
get_socket
();
}
}
zmq
::
tipc_connecter_t
::~
tipc_connecter_t
()
zmq
::
tipc_connecter_t
::~
tipc_connecter_t
()
{
{
zmq_assert
(
!
timer_started
);
zmq_assert
(
!
_
timer_started
);
zmq_assert
(
!
handle_valid
);
zmq_assert
(
!
_
handle_valid
);
zmq_assert
(
s
==
retired_fd
);
zmq_assert
(
_
s
==
retired_fd
);
}
}
void
zmq
::
tipc_connecter_t
::
process_plug
()
void
zmq
::
tipc_connecter_t
::
process_plug
()
{
{
if
(
delayed_start
)
if
(
_
delayed_start
)
add_reconnect_timer
();
add_reconnect_timer
();
else
else
start_connecting
();
start_connecting
();
...
@@ -91,17 +91,17 @@ void zmq::tipc_connecter_t::process_plug ()
...
@@ -91,17 +91,17 @@ void zmq::tipc_connecter_t::process_plug ()
void
zmq
::
tipc_connecter_t
::
process_term
(
int
linger_
)
void
zmq
::
tipc_connecter_t
::
process_term
(
int
linger_
)
{
{
if
(
timer_started
)
{
if
(
_
timer_started
)
{
cancel_timer
(
reconnect_timer_id
);
cancel_timer
(
reconnect_timer_id
);
timer_started
=
false
;
_
timer_started
=
false
;
}
}
if
(
handle_valid
)
{
if
(
_
handle_valid
)
{
rm_fd
(
handle
);
rm_fd
(
_
handle
);
handle_valid
=
false
;
_
handle_valid
=
false
;
}
}
if
(
s
!=
retired_fd
)
if
(
_
s
!=
retired_fd
)
close
();
close
();
own_t
::
process_term
(
linger_
);
own_t
::
process_term
(
linger_
);
...
@@ -118,8 +118,8 @@ void zmq::tipc_connecter_t::in_event ()
...
@@ -118,8 +118,8 @@ void zmq::tipc_connecter_t::in_event ()
void
zmq
::
tipc_connecter_t
::
out_event
()
void
zmq
::
tipc_connecter_t
::
out_event
()
{
{
fd_t
fd
=
connect
();
fd_t
fd
=
connect
();
rm_fd
(
handle
);
rm_fd
(
_
handle
);
handle_valid
=
false
;
_
handle_valid
=
false
;
// Handle the error condition by attempt to reconnect.
// Handle the error condition by attempt to reconnect.
if
(
fd
==
retired_fd
)
{
if
(
fd
==
retired_fd
)
{
...
@@ -129,22 +129,22 @@ void zmq::tipc_connecter_t::out_event ()
...
@@ -129,22 +129,22 @@ void zmq::tipc_connecter_t::out_event ()
}
}
// 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
);
// Attach the engine to the corresponding session object.
// Attach the engine to the corresponding session object.
send_attach
(
session
,
engine
);
send_attach
(
_
session
,
engine
);
// Shut the connecter down.
// Shut the connecter down.
terminate
();
terminate
();
socket
->
event_connected
(
endpoint
,
fd
);
_socket
->
event_connected
(
_
endpoint
,
fd
);
}
}
void
zmq
::
tipc_connecter_t
::
timer_event
(
int
id_
)
void
zmq
::
tipc_connecter_t
::
timer_event
(
int
id_
)
{
{
zmq_assert
(
id_
==
reconnect_timer_id
);
zmq_assert
(
id_
==
reconnect_timer_id
);
timer_started
=
false
;
_
timer_started
=
false
;
start_connecting
();
start_connecting
();
}
}
...
@@ -155,22 +155,22 @@ void zmq::tipc_connecter_t::start_connecting ()
...
@@ -155,22 +155,22 @@ void zmq::tipc_connecter_t::start_connecting ()
// Connect may succeed in synchronous manner.
// Connect may succeed in synchronous manner.
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
handle
=
add_fd
(
s
);
_handle
=
add_fd
(
_
s
);
handle_valid
=
true
;
_
handle_valid
=
true
;
out_event
();
out_event
();
}
}
// Connection establishment may be delayed. Poll for its completion.
// Connection establishment may be delayed. Poll for its completion.
else
if
(
rc
==
-
1
&&
errno
==
EINPROGRESS
)
{
else
if
(
rc
==
-
1
&&
errno
==
EINPROGRESS
)
{
handle
=
add_fd
(
s
);
_handle
=
add_fd
(
_
s
);
handle_valid
=
true
;
_
handle_valid
=
true
;
set_pollout
(
handle
);
set_pollout
(
_
handle
);
socket
->
event_connect_delayed
(
endpoint
,
zmq_errno
());
_socket
->
event_connect_delayed
(
_
endpoint
,
zmq_errno
());
}
}
// Handle any other error condition by eventual reconnect.
// Handle any other error condition by eventual reconnect.
else
{
else
{
if
(
s
!=
retired_fd
)
if
(
_
s
!=
retired_fd
)
close
();
close
();
add_reconnect_timer
();
add_reconnect_timer
();
}
}
...
@@ -181,8 +181,8 @@ void zmq::tipc_connecter_t::add_reconnect_timer ()
...
@@ -181,8 +181,8 @@ void zmq::tipc_connecter_t::add_reconnect_timer ()
if
(
options
.
reconnect_ivl
!=
-
1
)
{
if
(
options
.
reconnect_ivl
!=
-
1
)
{
int
rc_ivl
=
get_new_reconnect_ivl
();
int
rc_ivl
=
get_new_reconnect_ivl
();
add_timer
(
rc_ivl
,
reconnect_timer_id
);
add_timer
(
rc_ivl
,
reconnect_timer_id
);
socket
->
event_connect_retried
(
endpoint
,
rc_ivl
);
_socket
->
event_connect_retried
(
_
endpoint
,
rc_ivl
);
timer_started
=
true
;
_
timer_started
=
true
;
}
}
}
}
...
@@ -190,16 +190,16 @@ int zmq::tipc_connecter_t::get_new_reconnect_ivl ()
...
@@ -190,16 +190,16 @@ int zmq::tipc_connecter_t::get_new_reconnect_ivl ()
{
{
// The new interval is the current interval + random value.
// The new interval is the current interval + random value.
int
this_interval
=
int
this_interval
=
current_reconnect_ivl
+
(
generate_random
()
%
options
.
reconnect_ivl
);
_
current_reconnect_ivl
+
(
generate_random
()
%
options
.
reconnect_ivl
);
// Only change the current reconnect interval if the maximum reconnect
// Only change the current reconnect interval if the maximum reconnect
// interval was set and if it's larger than the reconnect interval.
// interval was set and if it's larger than the reconnect interval.
if
(
options
.
reconnect_ivl_max
>
0
if
(
options
.
reconnect_ivl_max
>
0
&&
options
.
reconnect_ivl_max
>
options
.
reconnect_ivl
)
{
&&
options
.
reconnect_ivl_max
>
options
.
reconnect_ivl
)
{
// Calculate the next interval
// Calculate the next interval
current_reconnect_ivl
=
current_reconnect_ivl
*
2
;
_current_reconnect_ivl
=
_
current_reconnect_ivl
*
2
;
if
(
current_reconnect_ivl
>=
options
.
reconnect_ivl_max
)
{
if
(
_
current_reconnect_ivl
>=
options
.
reconnect_ivl_max
)
{
current_reconnect_ivl
=
options
.
reconnect_ivl_max
;
_
current_reconnect_ivl
=
options
.
reconnect_ivl_max
;
}
}
}
}
return
this_interval
;
return
this_interval
;
...
@@ -207,27 +207,27 @@ int zmq::tipc_connecter_t::get_new_reconnect_ivl ()
...
@@ -207,27 +207,27 @@ int zmq::tipc_connecter_t::get_new_reconnect_ivl ()
int
zmq
::
tipc_connecter_t
::
open
()
int
zmq
::
tipc_connecter_t
::
open
()
{
{
zmq_assert
(
s
==
retired_fd
);
zmq_assert
(
_
s
==
retired_fd
);
// Cannot connect to random tipc addresses
// Cannot connect to random tipc addresses
if
(
addr
->
resolved
.
tipc_addr
->
is_random
())
{
if
(
_
addr
->
resolved
.
tipc_addr
->
is_random
())
{
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
// Create the socket.
// Create the socket.
s
=
open_socket
(
AF_TIPC
,
SOCK_STREAM
,
0
);
_
s
=
open_socket
(
AF_TIPC
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
if
(
_
s
==
-
1
)
return
-
1
;
return
-
1
;
// Set the non-blocking flag.
// Set the non-blocking flag.
unblock_socket
(
s
);
unblock_socket
(
_
s
);
// Connect to the remote peer.
// Connect to the remote peer.
#ifdef ZMQ_HAVE_VXWORKS
#ifdef ZMQ_HAVE_VXWORKS
int
rc
=
::
connect
(
s
,
(
sockaddr
*
)
addr
->
resolved
.
tipc_addr
->
addr
(),
int
rc
=
::
connect
(
s
,
(
sockaddr
*
)
addr
->
resolved
.
tipc_addr
->
addr
(),
addr
->
resolved
.
tipc_addr
->
addrlen
());
addr
->
resolved
.
tipc_addr
->
addrlen
());
#else
#else
int
rc
=
::
connect
(
s
,
addr
->
resolved
.
tipc_addr
->
addr
(),
int
rc
=
::
connect
(
_s
,
_
addr
->
resolved
.
tipc_addr
->
addr
(),
addr
->
resolved
.
tipc_addr
->
addrlen
());
_
addr
->
resolved
.
tipc_addr
->
addrlen
());
#endif
#endif
// Connect was successful immediately.
// Connect was successful immediately.
if
(
rc
==
0
)
if
(
rc
==
0
)
...
@@ -245,11 +245,11 @@ int zmq::tipc_connecter_t::open ()
...
@@ -245,11 +245,11 @@ int zmq::tipc_connecter_t::open ()
void
zmq
::
tipc_connecter_t
::
close
()
void
zmq
::
tipc_connecter_t
::
close
()
{
{
zmq_assert
(
s
!=
retired_fd
);
zmq_assert
(
_
s
!=
retired_fd
);
int
rc
=
::
close
(
s
);
int
rc
=
::
close
(
_
s
);
errno_assert
(
rc
==
0
);
errno_assert
(
rc
==
0
);
socket
->
event_closed
(
endpoint
,
s
);
_socket
->
event_closed
(
_endpoint
,
_
s
);
s
=
retired_fd
;
_
s
=
retired_fd
;
}
}
zmq
::
fd_t
zmq
::
tipc_connecter_t
::
connect
()
zmq
::
fd_t
zmq
::
tipc_connecter_t
::
connect
()
...
@@ -262,7 +262,7 @@ zmq::fd_t zmq::tipc_connecter_t::connect ()
...
@@ -262,7 +262,7 @@ zmq::fd_t zmq::tipc_connecter_t::connect ()
#else
#else
socklen_t
len
=
sizeof
(
err
);
socklen_t
len
=
sizeof
(
err
);
#endif
#endif
int
rc
=
getsockopt
(
s
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
err
,
&
len
);
int
rc
=
getsockopt
(
_
s
,
SOL_SOCKET
,
SO_ERROR
,
(
char
*
)
&
err
,
&
len
);
if
(
rc
==
-
1
)
if
(
rc
==
-
1
)
err
=
errno
;
err
=
errno
;
if
(
err
!=
0
)
{
if
(
err
!=
0
)
{
...
@@ -275,8 +275,8 @@ zmq::fd_t zmq::tipc_connecter_t::connect ()
...
@@ -275,8 +275,8 @@ zmq::fd_t zmq::tipc_connecter_t::connect ()
return
retired_fd
;
return
retired_fd
;
}
}
fd_t
result
=
s
;
fd_t
result
=
_
s
;
s
=
retired_fd
;
_
s
=
retired_fd
;
return
result
;
return
result
;
}
}
...
...
src/tipc_connecter.hpp
View file @
c94ad648
...
@@ -87,35 +87,35 @@ class tipc_connecter_t : public own_t, public io_object_t
...
@@ -87,35 +87,35 @@ class tipc_connecter_t : public own_t, public io_object_t
fd_t
connect
();
fd_t
connect
();
// Address to connect to. Owned by session_base_t.
// Address to connect to. Owned by session_base_t.
const
address_t
*
addr
;
const
address_t
*
_
addr
;
// 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
;
// If true file descriptor is registered with the poller and 'handle'
// If true file descriptor is registered with the poller and 'handle'
// contains valid value.
// contains valid value.
bool
handle_valid
;
bool
_
handle_valid
;
// If true, connecter is waiting a while before trying to connect.
// If true, connecter is waiting a while before trying to connect.
const
bool
delayed_start
;
const
bool
_
delayed_start
;
// True iff a timer has been started.
// True iff a timer has been started.
bool
timer_started
;
bool
_
timer_started
;
// Reference to the session we belong to.
// Reference to the session we belong to.
zmq
::
session_base_t
*
session
;
zmq
::
session_base_t
*
_
session
;
// Current reconnect ivl, updated for backoff strategy
// Current reconnect ivl, updated for backoff strategy
int
current_reconnect_ivl
;
int
_
current_reconnect_ivl
;
// String representation of endpoint to connect to
// String representation of endpoint to connect to
std
::
string
endpoint
;
std
::
string
_
endpoint
;
// Socket
// Socket
zmq
::
socket_base_t
*
socket
;
zmq
::
socket_base_t
*
_
socket
;
// Internal function to return a reconnect backoff delay.
// Internal function to return a reconnect backoff delay.
// Will modify the current_reconnect_ivl used for next call
// Will modify the current_reconnect_ivl used for next call
...
...
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