media_download tests: backpressure, block relay, OOB block_id, assembly
5 new tests in test_media_delivery_download: - conn_cb starts only first block (backpressure) - conn_cb with multiple peers - BLOCK_DONE triggers next block relay from same peer - assembly after all blocks validated - peer with more blocks than dl (OOB fix verification) md_dl_conn_cb made non-static for test visibility md_dl_send added NULL guard for test instances without routing media_download.h: added conn_cb extern declaration
This commit is contained in:
1 parent
41e9c9b0e6
commit
7263bdcf56
3 files changed
+202
-1
No files matched your search
@@ -57,6 +57,7 @@ static void md_mkdir_parent(const char* filepath) {
|
||||
}
|
||||
|
||||
static int md_dl_send(struct UTUN_INSTANCE* inst, uint64_t dst, const uint8_t* data, size_t len) {
|
||||
if (!inst || !inst->topo_groups || !inst->connections) { DEBUG_WARN(DEBUG_CATEGORY_GENERAL, "%s: md_dl_send: no routing (inst=%p topo=%p conn=%p)", MDL_ID, (void*)inst, (void*)(inst ? inst->topo_groups : NULL), (void*)(inst ? inst->connections : NULL)); return -1; }
|
||||
struct ll_entry* e = queue_entry_new(0);
|
||||
if (!e) { DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "%s: queue_entry_new failed for send to 0x%016llx", MDL_ID, (unsigned long long)dst); return -1; }
|
||||
e->dgram = u_malloc(len + 1);
|
||||
@@ -120,7 +121,7 @@ static void md_dl_send_have_block(struct UTUN_INSTANCE* inst, struct media_downl
|
||||
|
||||
/* ── conn_mgr callback ── */
|
||||
|
||||
static void md_dl_conn_cb(struct CONN_MGR_HANDLE* h, uint64_t node_id, uint64_t group_id,
|
||||
void md_dl_conn_cb(struct CONN_MGR_HANDLE* h, uint64_t node_id, uint64_t group_id,
|
||||
enum conn_mgr_event event, void* arg) {
|
||||
struct media_download* dl = (struct media_download*)arg;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: conn_cb event=%d node=0x%016llx dl=%p active=%d num_peers=%d num_blocks=%d",
|
||||
|
||||
@@ -105,6 +105,12 @@ void media_download_handle_done(struct UTUN_INSTANCE* inst,
|
||||
void media_download_handle_overloaded(struct UTUN_INSTANCE* inst,
|
||||
const uint8_t* data, size_t len);
|
||||
|
||||
/* ── conn_mgr callback (non-static for test visibility) ── */
|
||||
struct CONN_MGR_HANDLE;
|
||||
enum conn_mgr_event;
|
||||
void md_dl_conn_cb(struct CONN_MGR_HANDLE* h, uint64_t node_id, uint64_t group_id,
|
||||
enum conn_mgr_event event, void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user