@@ -1065,6 +1065,7 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e, pn_connection_t *pn_co
1065
1065
if (ctx && ctx -> connector ) { /* Outgoing connection */
1066
1066
const qd_server_config_t * config = & ctx -> connector -> config ;
1067
1067
char conn_msg [QD_CXTR_CONN_MSG_BUF_SIZE ]; // avoid holding connector lock when logging
1068
+ char conn_msg_1 [QD_CXTR_CONN_MSG_BUF_SIZE ]; // this connection message does not contain the connection id
1068
1069
1069
1070
sys_mutex_lock (& ctx -> connector -> lock );
1070
1071
qd_increment_conn_index_lh (ctx );
@@ -1074,14 +1075,32 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e, pn_connection_t *pn_co
1074
1075
qd_format_string (conn_msg , sizeof (conn_msg ), "[C%" PRIu64 "] Connection to %s failed: %s %s" ,
1075
1076
ctx -> connection_id , config -> host_port , pn_condition_get_name (condition ),
1076
1077
pn_condition_get_description (condition ));
1078
+
1079
+ qd_format_string (conn_msg_1 , sizeof (conn_msg_1 ), "Connection to %s failed: %s %s" ,
1080
+ config -> host_port , pn_condition_get_name (condition ), pn_condition_get_description (condition ));
1077
1081
} else {
1078
1082
qd_format_string (conn_msg , sizeof (conn_msg ), "[C%" PRIu64 "] Connection to %s failed" ,
1079
1083
ctx -> connection_id , config -> host_port );
1084
+ qd_format_string (conn_msg_1 , sizeof (conn_msg_1 ), "Connection to %s failed" , config -> host_port );
1085
+ }
1086
+ //
1087
+ // This is a fix for https://github.com/skupperproject/skupper-router/issues/1385
1088
+ // The router will repeatedly try to connect to the host/port specified in the connector
1089
+ // If it is unable to connect, an error message will be logged only once and more error messages
1090
+ // from connection failures will only be logged if the error message changes.
1091
+ // This is done so we don't flood the log with connection failure error messages
1092
+ // Even though we restrict the number of times the error message is displayed, the
1093
+ // router will still keep trying to connect to the host/port specified in the connector.
1094
+ //
1095
+ bool log_error_message = false;
1096
+ if (strcmp (ctx -> connector -> conn_msg , conn_msg_1 ) != 0 ) {
1097
+ strncpy (ctx -> connector -> conn_msg , conn_msg_1 , QD_CXTR_CONN_MSG_BUF_SIZE );
1098
+ log_error_message = true;
1080
1099
}
1081
- strncpy (ctx -> connector -> conn_msg , conn_msg , QD_CXTR_CONN_MSG_BUF_SIZE );
1082
1100
sys_mutex_unlock (& ctx -> connector -> lock );
1083
-
1084
- qd_log (LOG_SERVER , QD_LOG_ERROR , "%s" , conn_msg );
1101
+ if (log_error_message ) {
1102
+ qd_log (LOG_SERVER , QD_LOG_ERROR , "%s" , conn_msg );
1103
+ }
1085
1104
1086
1105
} else if (ctx && ctx -> listener ) { /* Incoming connection */
1087
1106
if (condition && pn_condition_is_set (condition )) {
0 commit comments