conn_mgr: resume recovery when local sockets change
This commit is contained in:
1 parent
8f5f2b089c
commit
a65ef30d78
3 files changed
+16
-1
No files matched your search
@@ -31,7 +31,7 @@ struct TOPO_GROUP;
|
||||
|
||||
enum conn_mgr_event {
|
||||
CONN_EVENT_UP = 0, /* связь есть. handle жив, можно отправлять данные */
|
||||
CONN_EVENT_DOWN = 1, /* связь потеряна; handle остаётся у владельца, успех восстановления не гарантирован */
|
||||
CONN_EVENT_DOWN = 1, /* все пути потеряны; восстановление продолжается, пока жив handle */
|
||||
CONN_EVENT_TIMEOUT = 2, /* подключение не удалось. handle жив, закройте сами */
|
||||
};
|
||||
|
||||
@@ -93,6 +93,9 @@ void conn_mgr_update_best_candidates(struct CONN_MGR* mgr, uint64_t node_id, uin
|
||||
/** Запланировать перепроверку путей после изменения маршрутов или READY групповых сессий. */
|
||||
void conn_mgr_routes_changed(struct CONN_MGR* mgr);
|
||||
|
||||
/** Изменились локальные сокеты: начать восстановление без ожидания backoff, сохраняя работающие пути. */
|
||||
void conn_mgr_network_changed(struct CONN_MGR* mgr);
|
||||
|
||||
/** Заимствованный next hop: READY прямой путь/подтверждённый посредник; allow_probe — только для управляющего обмена CM. */
|
||||
struct ETCP_CONN* conn_mgr_route_conn(struct CONN_MGR* mgr, uint64_t node_id, int allow_probe);
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
#include "config_parser.h"
|
||||
#include "../chat/chat_event.h"
|
||||
#include "../chat/chat_sync.h"
|
||||
#include "../routing_layer/topo_group.h"
|
||||
#include "../routing_layer/conn_mgr.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "../lib/u_async.h"
|
||||
@@ -238,6 +240,11 @@ static void auto_socket_post_sockets_changed(struct AUTO_SOCKET* as) {
|
||||
need_reconnect = 1;
|
||||
as->v4_addr_changed = 0; as->v6_addr_changed = 0;
|
||||
|
||||
struct TOPO_GROUPS* groups = as->instance->topo_groups;
|
||||
for (struct ll_entry* e = groups && groups->group_list ? groups->group_list->head : NULL; e; e = e->next) {
|
||||
struct TOPO_GROUP* group = (struct TOPO_GROUP*)e;
|
||||
if (!group->stopping) conn_mgr_network_changed(group->conn_mgr);
|
||||
}
|
||||
chat_event_post(as->instance, CHAT_EVT_LOCAL_SOCKETS, NULL, 0);
|
||||
|
||||
if (need_reconnect) {
|
||||
|
||||
@@ -206,6 +206,11 @@ static int ncd_add_tcp_link(struct ETCP_CONN* conn, struct ETCP_SOCKET* sock,
|
||||
(unsigned long long)conn->peer_node_id, link->local_link_id, link->link_status);
|
||||
if (!link->link_status) etcp_tcp_link_start_reconnect(link);
|
||||
}
|
||||
if (!link->link_status && !link->tcp_link && !link->tcp_reconnect_timer) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NCD, "[ncd] resume idle TCP probe node=%016llx link=%u",
|
||||
(unsigned long long)conn->peer_node_id, link->local_link_id);
|
||||
etcp_tcp_link_start_reconnect(link);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
struct ETCP_LINK* link = etcp_link_new(conn, sock, addr, 0);
|
||||
|
||||
Reference in new issue
Block a user