mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: formatting errors
Solution: run make clang-format-diff
This commit is contained in:
parent
c04f6581e0
commit
1ddfeb56ec
@ -697,8 +697,9 @@ void zmq::stream_engine_base_t::error (error_reason_t reason_)
|
||||
// special case: connecting to non-ZMTP process which immediately drops connection,
|
||||
// or which never responds with greeting, should be treated as a protocol error
|
||||
// (i.e. stop reconnect)
|
||||
if ( ( (reason_ == connection_error) || (reason_ == timeout_error) )
|
||||
&& (_options.reconnect_stop & ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED)) {
|
||||
if (((reason_ == connection_error) || (reason_ == timeout_error))
|
||||
&& (_options.reconnect_stop
|
||||
& ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED)) {
|
||||
reason_ = protocol_error;
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void reconnect_stop_on_handshake_failed ()
|
||||
{
|
||||
char bind_address[MAX_SOCKET_STRING];
|
||||
size_t addr_length = sizeof (bind_address);
|
||||
void* dummy = test_context_socket (ZMQ_STREAM);
|
||||
void *dummy = test_context_socket (ZMQ_STREAM);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (dummy, "tcp://127.0.0.1:0"));
|
||||
TEST_ASSERT_SUCCESS_ERRNO (
|
||||
zmq_getsockopt (dummy, ZMQ_LAST_ENDPOINT, bind_address, &addr_length));
|
||||
@ -240,9 +240,8 @@ void reconnect_stop_on_handshake_failed ()
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub_mon, "inproc://monitor-sub"));
|
||||
// set handshake interval (i.e., timeout) to a more reasonable value
|
||||
int handshakeInterval = 1000;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sub, ZMQ_HANDSHAKE_IVL,
|
||||
&handshakeInterval,
|
||||
sizeof (handshakeInterval)));
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (
|
||||
sub, ZMQ_HANDSHAKE_IVL, &handshakeInterval, sizeof (handshakeInterval)));
|
||||
// set option to stop reconnecting on failed handshake
|
||||
int stopReconnectOnError = ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED;
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sub, ZMQ_RECONNECT_STOP,
|
||||
@ -251,15 +250,15 @@ void reconnect_stop_on_handshake_failed ()
|
||||
// connect to dummy stream socket above
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub, bind_address));
|
||||
|
||||
#if 1
|
||||
#if 1
|
||||
// ZMQ_EVENT_DISCONNECTED should be last event, because of ZMQ_RECONNECT_STOP set above
|
||||
expect_monitor_event (sub_mon, ZMQ_EVENT_CONNECT_DELAYED);
|
||||
expect_monitor_event (sub_mon, ZMQ_EVENT_CONNECTED);
|
||||
expect_monitor_event (sub_mon, ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL);
|
||||
expect_monitor_event (sub_mon, ZMQ_EVENT_DISCONNECTED);
|
||||
#else
|
||||
print_events(sub_mon, 2 * 1000, 1000);
|
||||
#endif
|
||||
#else
|
||||
print_events (sub_mon, 2 * 1000, 1000);
|
||||
#endif
|
||||
|
||||
// Close sub
|
||||
// TODO why does this use zero_linger?
|
||||
@ -290,9 +289,9 @@ int main (void)
|
||||
|
||||
RUN_TEST (reconnect_default);
|
||||
RUN_TEST (reconnect_success);
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
RUN_TEST (reconnect_stop_on_refused);
|
||||
RUN_TEST (reconnect_stop_on_handshake_failed);
|
||||
#endif
|
||||
#endif
|
||||
return UNITY_END ();
|
||||
}
|
||||
|
@ -345,41 +345,57 @@ void expect_monitor_event_v2 (void *monitor_,
|
||||
}
|
||||
|
||||
|
||||
const char* get_zmqEventName(uint64_t event)
|
||||
const char *get_zmqEventName (uint64_t event)
|
||||
{
|
||||
switch(event) {
|
||||
case ZMQ_EVENT_CONNECTED : return "CONNECTED";
|
||||
case ZMQ_EVENT_CONNECT_DELAYED : return "CONNECT_DELAYED";
|
||||
case ZMQ_EVENT_CONNECT_RETRIED : return "CONNECT_RETRIED";
|
||||
case ZMQ_EVENT_LISTENING : return "LISTENING";
|
||||
case ZMQ_EVENT_BIND_FAILED : return "BIND_FAILED";
|
||||
case ZMQ_EVENT_ACCEPTED : return "ACCEPTED";
|
||||
case ZMQ_EVENT_ACCEPT_FAILED : return "ACCEPT_FAILED";
|
||||
case ZMQ_EVENT_CLOSED : return "CLOSED";
|
||||
case ZMQ_EVENT_CLOSE_FAILED : return "CLOSE_FAILED";
|
||||
case ZMQ_EVENT_DISCONNECTED : return "DISCONNECTED";
|
||||
case ZMQ_EVENT_MONITOR_STOPPED : return "MONITOR_STOPPED";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL : return "HANDSHAKE_FAILED_NO_DETAIL";
|
||||
case ZMQ_EVENT_HANDSHAKE_SUCCEEDED : return "HANDSHAKE_SUCCEEDED";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL : return "HANDSHAKE_FAILED_PROTOCOL";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH : return "HANDSHAKE_FAILED_AUTH";
|
||||
default : return "UNKNOWN";
|
||||
switch (event) {
|
||||
case ZMQ_EVENT_CONNECTED:
|
||||
return "CONNECTED";
|
||||
case ZMQ_EVENT_CONNECT_DELAYED:
|
||||
return "CONNECT_DELAYED";
|
||||
case ZMQ_EVENT_CONNECT_RETRIED:
|
||||
return "CONNECT_RETRIED";
|
||||
case ZMQ_EVENT_LISTENING:
|
||||
return "LISTENING";
|
||||
case ZMQ_EVENT_BIND_FAILED:
|
||||
return "BIND_FAILED";
|
||||
case ZMQ_EVENT_ACCEPTED:
|
||||
return "ACCEPTED";
|
||||
case ZMQ_EVENT_ACCEPT_FAILED:
|
||||
return "ACCEPT_FAILED";
|
||||
case ZMQ_EVENT_CLOSED:
|
||||
return "CLOSED";
|
||||
case ZMQ_EVENT_CLOSE_FAILED:
|
||||
return "CLOSE_FAILED";
|
||||
case ZMQ_EVENT_DISCONNECTED:
|
||||
return "DISCONNECTED";
|
||||
case ZMQ_EVENT_MONITOR_STOPPED:
|
||||
return "MONITOR_STOPPED";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL:
|
||||
return "HANDSHAKE_FAILED_NO_DETAIL";
|
||||
case ZMQ_EVENT_HANDSHAKE_SUCCEEDED:
|
||||
return "HANDSHAKE_SUCCEEDED";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL:
|
||||
return "HANDSHAKE_FAILED_PROTOCOL";
|
||||
case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH:
|
||||
return "HANDSHAKE_FAILED_AUTH";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
void print_events(void* socket, int timeout, int limit)
|
||||
void print_events (void *socket, int timeout, int limit)
|
||||
{
|
||||
// print events received
|
||||
int value;
|
||||
char *event_address;
|
||||
int event = get_monitor_event_with_timeout (socket, &value, &event_address,
|
||||
timeout);
|
||||
int i = 0;;
|
||||
int event =
|
||||
get_monitor_event_with_timeout (socket, &value, &event_address, timeout);
|
||||
int i = 0;
|
||||
;
|
||||
while ((event != -1) && (++i < limit)) {
|
||||
const char* eventName = get_zmqEventName(event);
|
||||
printf("Got event: %s\n", eventName);
|
||||
const char *eventName = get_zmqEventName (event);
|
||||
printf ("Got event: %s\n", eventName);
|
||||
event = get_monitor_event_with_timeout (socket, &value, &event_address,
|
||||
timeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void expect_monitor_event_v2 (void *monitor_,
|
||||
const char *expected_remote_address_ = NULL);
|
||||
|
||||
|
||||
const char* get_zmqEventName(uint64_t event);
|
||||
void print_events(void* socket, int timeout, int limit);
|
||||
const char *get_zmqEventName (uint64_t event);
|
||||
void print_events (void *socket, int timeout, int limit);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user