Wait for target discovery before member file network transfers
This commit is contained in:
1 parent
4314dff390
commit
10d6ddee38
1 file changed
+13
-8
@@ -7,6 +7,7 @@
|
||||
#include "../src/chat/chat_event.h"
|
||||
#include "../src/chat/member_sync.h"
|
||||
#include "../src/routing_layer/topo_node_sqlite.h"
|
||||
#include "../src/routing_layer/topo_node.h"
|
||||
#include "../src/routing_layer/etcp_router.h"
|
||||
#include "../src/transport_layer/etcp.h"
|
||||
#include "../src/transport_layer/secure_channel.h"
|
||||
@@ -277,14 +278,18 @@ static void tick(void* arg) {
|
||||
struct ETCP_ROUTER_CONN* route = etcp_router_conn_get(t->nodes[AUTHOR], GROUP, t->ids[SERVER], ETCP_RT_ID_MEMBER_FILES);
|
||||
if (route->inflight_q->count > t->peak_inflight) t->peak_inflight = route->inflight_q->count;
|
||||
if (t->phase == 0) {
|
||||
if (t->ticks == 1) {
|
||||
struct member_files* files = t->nodes[SERVER]->member_files;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "member_files test: startup tick=%u storage_status=%d closing=%d server=%llx",
|
||||
t->ticks, files->storage_status, files->closing, (unsigned long long)t->ids[SERVER]);
|
||||
}
|
||||
int a = etcp_router_get_path(t->nodes[AUTHOR], GROUP, t->ids[SERVER], ETCP_RT_ID_MEMBER_FILES).next_hop_node_id != 0;
|
||||
int b = etcp_router_get_path(t->nodes[READER], GROUP, t->ids[SERVER], ETCP_RT_ID_MEMBER_FILES).next_hop_node_id != 0;
|
||||
if (a && b && t->nodes[SERVER]->member_files->storage_status == MF_OK) { t->phase = 1; transfer(t, 1, 1); }
|
||||
/* CM нужен известный адрес цели; готовность storage не означает, что NODEINFO уже дошёл до клиентов.
|
||||
* Не открываем CM заранее: запрос маршрута по-прежнему принадлежит самой передаче. */
|
||||
struct TOPO_NODE* author_node = topo_node_registry_find(t->nodes[AUTHOR]->topo_groups, t->ids[SERVER]);
|
||||
struct TOPO_NODE* reader_node = topo_node_registry_find(t->nodes[READER]->topo_groups, t->ids[SERVER]);
|
||||
int author_ready = author_node && author_node->timestamp && (author_node->v4_addrs || author_node->v6_addrs);
|
||||
int reader_ready = reader_node && reader_node->timestamp && (reader_node->v4_addrs || reader_node->v6_addrs);
|
||||
if (t->nodes[SERVER]->member_files->storage_status == MF_OK && author_ready && reader_ready) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "member_files test: storage and target snapshots ready; upload opens its own CM route request");
|
||||
t->phase = 1; transfer(t, 1, 1);
|
||||
} else if (t->ticks == 1 || t->ticks % 100 == 0)
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files test: waiting for setup storage=%s author_snapshot=%d reader_snapshot=%d",
|
||||
mf_status_text(t->nodes[SERVER]->member_files->storage_status), author_ready, reader_ready);
|
||||
} else if (t->phase == 1 && t->finished) {
|
||||
if (t->transfer_status) { fail(t, mf_status_text(t->transfer_status)); return; }
|
||||
t->phase = 2; request(t, MF_STAT, t->ids[AUTHOR]);
|
||||
|
||||
Reference in new issue
Block a user