From 06ea3d4d1b3147e98a3ab6b7e4008ed83b28967c Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 5 Sep 2017 20:27:58 +0200 Subject: [PATCH] main: better connection messages --- kernel/sy_old/mars_main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/kernel/sy_old/mars_main.c b/kernel/sy_old/mars_main.c index b3229ede..e35a3fda 100644 --- a/kernel/sy_old/mars_main.c +++ b/kernel/sy_old/mars_main.c @@ -2209,6 +2209,7 @@ int peer_thread(void *data) }; int pause_time = 0; bool do_kill = false; + bool repeated = false; int status; if (!peer || !mars_net_is_alive) @@ -2241,8 +2242,11 @@ int peer_thread(void *data) init_rwsem(&tmp_global.dent_mutex); init_rwsem(&tmp_global.brick_mutex); - report_peer_connection(peer_pairs, peer->do_additional); - report_peer_connection(peer_pairs, !peer->do_additional); + if (likely(repeated)) { + report_peer_connection(peer_pairs, !peer->do_communicate); + report_peer_connection(peer_pairs, peer->do_communicate); + } + repeated = true; if (!mars_socket_is_alive(&peer->socket)) { make_msg(peer_pairs, "connection to '%s' (%s) is dead", peer->peer, real_peer); @@ -2279,6 +2283,7 @@ int peer_thread(void *data) peer->socket.s_send_abort = mars_peer_abort; peer->socket.s_recv_abort = mars_peer_abort; MARS_DBG("successfully opened socket to '%s'\n", real_peer); + clear_vals(peer_pairs); brick_msleep(100); continue; } else { @@ -2430,9 +2435,11 @@ int peer_thread(void *data) MARS_INF("-------- peer thread terminating\n"); - make_msg(peer_pairs, "NOT connected %s(%s)", peer->peer, real_peer); - report_peer_connection(peer_pairs, peer->do_additional); - report_peer_connection(peer_pairs, !peer->do_additional); + clear_vals(peer_pairs); + if (peer->do_communicate) + make_msg(peer_pairs, "NOT connected %s(%s)", peer->peer, real_peer); + report_peer_connection(peer_pairs, !peer->do_communicate); + report_peer_connection(peer_pairs, peer->do_communicate); peer->do_additional = false; if (peer->doing_additional) {