Negotiate frozen-rate stream cuts with bounded overload grace

This commit is contained in:
evgeny committed 2026-10-12 00:01:39 +02:00
1 parent f2500f8ad7
commit 6bf396af8e
1 file changed
+293 -5
+293 -5
View File
@@ -21,7 +21,7 @@
#define STREAM_TICK_TB 1000
struct stream_peer;
struct stream_cut { uint64_t handle, rate; int closed; };
struct stream_cut { uint64_t handle, rate; int closed, selected; };
struct stream_pressure_request {
struct stream_cut cuts[STREAM_OVERLOAD_MAX];
uint64_t id, required_rate, released_rate, deadline_ms;
@@ -67,6 +67,8 @@ struct stream_network {
struct uasync_load cpu;
uint64_t next_tick_ms, callback_late_ms;
int global_pressure;
uint64_t local_busy_until_ms, global_since_ms;
int global_candidate;
};
static void peer_pump(void *arg);
@@ -76,6 +78,16 @@ static void receive_routed(struct ETCP_CONN *conn, struct ll_entry *entry);
static void pressure_tick(struct stream_network *net, uint64_t now);
static void pressure_receive(struct stream_peer *peer, const struct stream_message *message);
/* Ключи очереди — cursor+кольцо, её возраст учитывает реальное время вставки и момент появления выдачи. */
static uint64_t flow_age(struct STREAM_RECEIVE *f, uint64_t now) {
if (f->outgoing || !f->load.queued.packets) return 0;
struct stream_local local; uint64_t oldest = 0;
if (stream_local_get(f->peer->network->inst, &f->descriptor, &local) != STREAM_OK) return 0;
if (stream_buffer_pending(local.buffer, f->info.next, f->subblock, NULL, &oldest) != STREAM_OK) return 0;
if (oldest < f->admitted_ms) oldest = f->admitted_ms;
return now > oldest ? now - oldest : 0;
}
/* Один блок принадлежит логической очереди выдачи/пира/модуля; ни одна из них не хранит копию DATA. */
static void load_account(struct STREAM_RECEIVE *f, uint64_t packets, uint64_t bytes, int added, int sent) {
if (!packets) return;
@@ -133,7 +145,8 @@ static void peer_cancel_wait(struct stream_peer *p) {
static int control_put(struct stream_peer *p, struct stream_message m, const uint8_t *payload, size_t length) {
if (length + STREAM_WIRE_HEADER > STREAM_CONTROL_MAX || p->control->count >= STREAM_CONTROL_LIMIT) {
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream control limit peer=%llx count=%d command=%u bytes=%zu",
(unsigned long long)p->node_id, p->control->count, m.command, length); return STREAM_ERR_STATE;
(unsigned long long)p->node_id, p->control->count, m.command, length);
p->load.rejected++; p->network->load.rejected++; return STREAM_ERR_STATE;
}
struct ll_entry *e = ll_alloc_lldgram((uint16_t)(STREAM_WIRE_HEADER + length));
if (!e) { DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "stream control allocation failed command=%u", m.command); return STREAM_ERR_MEMORY; }
@@ -432,7 +445,8 @@ static int downstream_send(struct STREAM_RECEIVE *f) {
if (local.finished && local.last != UINT64_MAX && f->info.next > local.last) {
m.command = STREAM_CMD_END;
if (raw_send(p, m, local.end, STREAM_END_SIZE) == STREAM_OK) {
f->info.state = STREAM_RECEIVE_ENDED; return 1;
f->info.state = STREAM_RECEIVE_ENDED; stream_metrics_end(&f->offered_metrics);
stream_load_changed(&p->load); stream_load_changed(&p->network->load); return 1;
}
flow_close(f, STREAM_REASON_TRANSPORT, 0);
}
@@ -504,6 +518,7 @@ static void peer_pump(void *arg) {
struct STREAM_RECEIVE *first = p->last_sent && p->last_sent->next ? p->last_sent->next : p->flows;
struct STREAM_RECEIVE *f = first;
while (f) {
if (f->account_failed) flow_close(f, STREAM_REASON_PROTOCOL, 1);
if (!f->outgoing && f->info.state == STREAM_RECEIVE_ACTIVE && downstream_send(f)) { p->last_sent = f; sent = 1; break; }
f = f->next ? f->next : p->flows;
if (f == first) break;
@@ -526,6 +541,10 @@ static void subscribe_request(struct stream_peer *p, struct stream_message m, st
uint64_t requested = m.length == 8 ? stream_read_be(m.payload, 8) : 0;
if (f && f->requested != requested) reason = STREAM_REASON_CONFLICT;
if (!f && !reason && m.handle <= p->highwater) reason = STREAM_REASON_STALE;
if (!f && !reason && (p->pressure.active || p->cooling)) {
p->highwater = m.handle; reason = STREAM_REASON_OVERLOAD;
p->load.rejected++; p->network->load.rejected++;
}
if (!f && !reason) {
p->highwater = m.handle;
reason = info_payload(local, m.subblock, requested, p->node_id, p->network->inst->node_id, payload);
@@ -754,6 +773,7 @@ static void network_tick(void *arg) {
p->busy++;
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next) {
if (f->info.state == STREAM_RECEIVE_CLOSED) continue;
f->info.metrics_valid = stream_metrics_poll(&f->metrics, now_ms, &f->info.metrics) == STREAM_OK;
if ((!f->outgoing || f->info.state < STREAM_RECEIVE_ACTIVE) && now >= f->deadline)
flow_close(f, f->info.state < STREAM_RECEIVE_ACTIVE ? STREAM_REASON_TRANSPORT : STREAM_REASON_LEASE, 1);
else if (f->outgoing && f->info.state >= STREAM_RECEIVE_ACTIVE && now - f->renewed >= STREAM_RENEW_TB) {
@@ -905,9 +925,9 @@ int stream_receive_restart(struct STREAM_HANDLE *subscription) {
int stream_receive_get_info(const struct STREAM_RECEIVE *f, struct stream_receive_info *info) {
if (!f || !info) { DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "stream receive info invalid arguments"); return STREAM_ERR_ARGUMENT; }
*info = f->info;
info->metrics_valid = stream_metrics_poll((struct stream_metrics *)&f->metrics, get_time_tb() / 10, &info->metrics) == STREAM_OK;
/* Poll таймером сохраняет историю остановок; getter не меняет состояние const handle. */
if (f->peer && f->peer->requested.active) for (unsigned i = 0; i < f->peer->requested.count; i++)
if (f->peer->requested.cuts[i].handle == f->info.handle) info->close_requested = 1;
if (f->peer->requested.cuts[i].selected && f->peer->requested.cuts[i].handle == f->info.handle) info->close_requested = 1;
return STREAM_OK;
}
@@ -928,3 +948,271 @@ void stream_network_cache_event(struct stream_network *net, const struct stream_
}
}
}
/* Нужна скорость входящего вклада, а не урезанный D. При отсутствии source-дельты используем измеренные arrivals. */
static uint64_t flow_rate(struct STREAM_RECEIVE *f, uint64_t now) {
struct stream_metric_snapshot metric = {0};
stream_metrics_poll(&f->offered_metrics, now, &metric);
uint64_t rate = metric.source_rate_valid && !metric.stopped ? metric.source_rate_bytes_sec : f->load.snapshot.input_rate;
return rate ? rate : 1;
}
static struct STREAM_RECEIVE *flow_by_handle(struct stream_peer *p, uint64_t handle, int outgoing) {
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next)
if (f->outgoing == outgoing && f->info.handle == handle && f->info.state == STREAM_RECEIVE_ACTIVE) return f;
return NULL;
}
/* Rate фиксируется один раз. Высокие rates первыми определяют расчётное число закрытий, но получатель вправе выбрать другие handles. */
static int pressure_begin(struct stream_peer *p, uint64_t required, uint64_t now) {
if (p->pressure.active || p->cooling) return 0;
struct stream_pressure_request request = {0}; uint64_t total = 0;
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next) {
if (f->outgoing || f->info.state != STREAM_RECEIVE_ACTIVE) continue;
struct stream_cut cut = {.handle = f->info.handle, .rate = flow_rate(f, now)};
unsigned at = request.count++;
while (at && request.cuts[at - 1].rate < cut.rate) { request.cuts[at] = request.cuts[at - 1]; at--; }
request.cuts[at] = cut; total += cut.rate;
}
if (!request.count) return 0;
if (p->pressure_id == UINT64_MAX) { DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "stream OVERLOAD id exhausted"); return 0; }
request.required_rate = required && required < total ? required : total;
uint64_t picked = 0;
while (request.required_count < request.count && picked < request.required_rate) picked += request.cuts[request.required_count++].rate;
request.id = ++p->pressure_id; request.deadline_ms = now + STREAM_LOAD_GRACE_MS; request.active = 1;
p->pressure = request; p->pressure_retry_ms = 0; p->clear_since_ms = 0;
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream OVERLOAD begin peer=%llx id=%llu count=%u cut=%llu g=%llu A=%llu D=%llu X=%llu Q=%llu age=%llu global=%d",
(unsigned long long)p->node_id, (unsigned long long)request.id, request.required_count,
(unsigned long long)request.required_rate, (unsigned long long)p->load.snapshot.growth_rate,
(unsigned long long)p->load.arrivals.bytes, (unsigned long long)p->load.sent.bytes,
(unsigned long long)p->load.removed.bytes, (unsigned long long)p->load.queued.bytes,
(unsigned long long)p->load.snapshot.oldest_age_ms, p->network->global_pressure);
return 1;
}
/* Повтор запроса не меняет rate/срок. Header несёт один активный ключ, а список handles относится ко всем группам пира. */
static void pressure_send(struct stream_peer *p, uint64_t now) {
if (!p->pressure.active || (p->pressure_retry_ms && now - p->pressure_retry_ms < 500)) return;
struct STREAM_RECEIVE *first = NULL;
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next)
if (!f->outgoing && f->info.state == STREAM_RECEIVE_ACTIVE) { first = f; break; }
if (!first) return;
uint8_t payload[STREAM_OVERLOAD_HEADER + STREAM_OVERLOAD_MAX * 16];
stream_write_be(payload, p->pressure.id, 8); stream_write_be(payload + 8, p->pressure.required_rate, 8);
payload[16] = (uint8_t)p->pressure.required_count; payload[17] = (uint8_t)p->pressure.count;
for (unsigned i = 0; i < p->pressure.count; i++) {
stream_write_be(payload + STREAM_OVERLOAD_HEADER + i * 16, p->pressure.cuts[i].handle, 8);
stream_write_be(payload + STREAM_OVERLOAD_HEADER + i * 16 + 8, p->pressure.cuts[i].rate, 8);
}
struct stream_message m = {.descriptor = first->descriptor, .command = STREAM_CMD_OVERLOAD};
if (control_put(p, m, payload, STREAM_OVERLOAD_HEADER + p->pressure.count * 16) == STREAM_OK) p->pressure_retry_ms = now;
}
/* Оценить возможность убрать один субпоток без потери k: учитываем дубликаты и остальных поставщиков. */
static int removal_cost(struct stream_peer *p, struct STREAM_RECEIVE *candidate) {
uint8_t seen[RS_MAX_BLOCKS] = {0}; unsigned distinct = 0;
for (struct stream_peer *other = p->network->peers; other; other = other->next) {
for (struct STREAM_RECEIVE *f = other->flows; f; f = f->next) {
if (!f->outgoing || f == candidate || f->info.state != STREAM_RECEIVE_ACTIVE
|| !same_stream(&f->descriptor, &candidate->descriptor)) continue;
int selected = 0;
if (other == p) for (unsigned i = 0; i < p->requested.count; i++)
if (p->requested.cuts[i].selected && p->requested.cuts[i].handle == f->info.handle) selected = 1;
if (!selected && !seen[f->subblock]) { seen[f->subblock] = 1; distinct++; }
}
}
return distinct >= (unsigned)(candidate->descriptor.n - candidate->descriptor.r) ? 0 : 1;
}
/* Выбор лишь предлагает source закрытия. Клиент не отсоединяет handles до CLOSED: поздний SELECT не режет лишние после fallback. */
static void pressure_select(struct stream_peer *p, uint64_t now) {
struct stream_pressure_request *r = &p->requested;
if (!r->active || r->sent || now >= r->deadline_ms) return;
uint64_t reduction = 0; unsigned selected = 0;
for (unsigned i = 0; i < r->count; i++) if (r->cuts[i].selected) { reduction += r->cuts[i].rate; selected++; }
while (reduction < r->required_rate) {
int best = -1, best_cost = 2;
for (unsigned i = 0; i < r->count; i++) {
struct STREAM_RECEIVE *f = flow_by_handle(p, r->cuts[i].handle, 1);
if (r->cuts[i].selected || !f) continue;
int cost = removal_cost(p, f);
if (cost < best_cost || (cost == best_cost && (best < 0 || r->cuts[i].rate > r->cuts[best].rate))) {
best = (int)i; best_cost = cost;
}
}
if (best < 0) break;
r->cuts[best].selected = 1; reduction += r->cuts[best].rate; selected++;
}
if (!selected) return;
uint8_t payload[9 + STREAM_OVERLOAD_MAX * 8]; stream_write_be(payload, r->id, 8); payload[8] = (uint8_t)selected;
struct STREAM_RECEIVE *first = NULL; unsigned at = 0;
for (unsigned i = 0; i < r->count; i++) if (r->cuts[i].selected) {
stream_write_be(payload + 9 + at++ * 8, r->cuts[i].handle, 8);
if (!first) first = flow_by_handle(p, r->cuts[i].handle, 1);
}
if (!first) return;
struct stream_message m = {.descriptor = first->descriptor, .command = STREAM_CMD_OVERLOAD_SELECT};
if (control_put(p, m, payload, 9 + at * 8) == STREAM_OK) {
r->sent = 1;
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "stream OVERLOAD selected peer=%llx id=%llu handles=%u rate=%llu requested=%llu",
(unsigned long long)p->node_id, (unsigned long long)r->id, at,
(unsigned long long)reduction, (unsigned long long)r->required_rate);
}
}
/* Проверяем весь список до действия: повторы handles и несуществующие элементы не создают частичных закрытий. */
static void pressure_receive(struct stream_peer *p, const struct stream_message *m) {
uint64_t now = get_time_tb() / 10;
if (m->command == STREAM_CMD_OVERLOAD) {
if (m->length < STREAM_OVERLOAD_HEADER) goto malformed;
unsigned count = m->payload[17]; uint64_t id = stream_read_be(m->payload, 8), required = stream_read_be(m->payload + 8, 8);
if (!id || !required || !count || count > STREAM_OVERLOAD_MAX || !m->payload[16] || m->payload[16] > count
|| m->length != STREAM_OVERLOAD_HEADER + count * 16) goto malformed;
if (id <= p->requested.id) return;
struct stream_pressure_request request = {.id = id, .required_rate = required, .required_count = m->payload[16],
.count = count, .deadline_ms = now + STREAM_LOAD_GRACE_MS, .active = 1};
uint64_t total = 0;
for (unsigned i = 0; i < count; i++) {
request.cuts[i].handle = stream_read_be(m->payload + STREAM_OVERLOAD_HEADER + i * 16, 8);
request.cuts[i].rate = stream_read_be(m->payload + STREAM_OVERLOAD_HEADER + i * 16 + 8, 8);
if (!request.cuts[i].handle || !request.cuts[i].rate || request.cuts[i].rate > UINT64_MAX - total) goto malformed;
for (unsigned j = 0; j < i; j++) if (request.cuts[j].handle == request.cuts[i].handle) goto malformed;
total += request.cuts[i].rate;
}
if (required > total) goto malformed;
p->requested = request; pressure_select(p, now); return;
}
if (m->length < 9) goto malformed;
unsigned count = m->payload[8]; uint64_t id = stream_read_be(m->payload, 8);
if (!id || !count || count > STREAM_OVERLOAD_MAX || m->length != 9 + count * 8) goto malformed;
if (!p->pressure.active || id != p->pressure.id || now >= p->pressure.deadline_ms) {
DEBUG_DEBUG(DEBUG_CATEGORY_STREAM, "stream stale OVERLOAD_SELECT peer=%llx id=%llu",
(unsigned long long)p->node_id, (unsigned long long)id); return;
}
for (unsigned i = 0; i < count; i++) {
uint64_t handle = stream_read_be(m->payload + 9 + i * 8, 8); int found = 0;
for (unsigned j = 0; j < p->pressure.count; j++) if (p->pressure.cuts[j].handle == handle) found = 1;
for (unsigned j = 0; j < i; j++) if (stream_read_be(m->payload + 9 + j * 8, 8) == handle) goto malformed;
if (!found) goto malformed;
}
for (unsigned i = 0; i < count && p->pressure.released_rate < p->pressure.required_rate; i++) {
struct STREAM_RECEIVE *f = flow_by_handle(p, stream_read_be(m->payload + 9 + i * 8, 8), 0);
if (f) flow_close(f, STREAM_REASON_OVERLOAD, 1);
}
return;
malformed:
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream malformed pressure command=%u peer=%llx bytes=%zu", m->command,
(unsigned long long)p->node_id, m->length);
}
/* Просроченные ключи удаляются X; сохранённое кольцо не стирается и GAP обязательно предшествует дальнейшим DATA. */
static void expire_pending(struct STREAM_RECEIVE *f) {
if (!f->gap_pending) f->gap_from = f->info.next;
f->info.next = f->pending_highest + 1; f->gap_pending = 1;
load_account(f, f->load.queued.packets, f->load.queued.bytes, 0, 0);
peer_schedule(f->peer);
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream pending expired peer=%llx handle=%llu first=%llu next=%llu",
(unsigned long long)f->peer->node_id, (unsigned long long)f->info.handle,
(unsigned long long)f->gap_from, (unsigned long long)f->info.next);
}
/* 100-мс обход не отправляет DATA и не заменяет waiter. Метрики фиксируются с фактическим периодом >=200мс. */
static void pressure_tick(struct stream_network *net, uint64_t now) {
unsigned troubled = 0; uint64_t maximum_age = 0;
for (struct stream_peer *p = net->peers; p; p = p->next) {
uint64_t oldest = 0;
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next) {
uint64_t age = flow_age(f, now); if (age > oldest) oldest = age;
struct stream_load_snapshot snapshot; stream_load_poll(&f->load, now, age, &snapshot);
}
struct stream_load_snapshot snapshot;
int sampled = stream_load_poll(&p->load, now, oldest, &snapshot) == STREAM_OK;
if (snapshot.pressure) troubled++;
if (oldest > maximum_age) maximum_age = oldest;
if (sampled && p->load.queued.bytes) DEBUG_DEBUG(DEBUG_CATEGORY_STREAM,
"stream load peer=%llx A=%llu D=%llu X=%llu Q=%llu age=%llu input=%llu output=%llu g=%llu interval=%llu confirm=%d",
(unsigned long long)p->node_id, (unsigned long long)snapshot.arrivals.bytes, (unsigned long long)snapshot.sent.bytes,
(unsigned long long)snapshot.removed.bytes, (unsigned long long)snapshot.queued.bytes, (unsigned long long)oldest,
(unsigned long long)snapshot.input_rate, (unsigned long long)snapshot.output_rate,
(unsigned long long)snapshot.growth_rate, (unsigned long long)snapshot.interval_ms, snapshot.confirmed);
}
struct stream_load_snapshot global; stream_load_poll(&net->load, now, maximum_age, &global);
if (net->callback_late_ms >= 200 || (net->cpu.valid && net->cpu.average_percent >= 90)) net->local_busy_until_ms = now + 1000;
int global_condition = troubled >= 2 && global.pressure && now < net->local_busy_until_ms;
if (!global_condition) net->global_candidate = 0;
else if (!net->global_candidate) { net->global_candidate = 1; net->global_since_ms = now; }
net->global_pressure = net->global_candidate && now - net->global_since_ms >= STREAM_LOAD_CONFIRM_MS;
if (net->global_pressure) {
uint64_t required = global.growth_rate ? global.growth_rate + global.growth_rate / 10 + 1 : global.queued.bytes / 2 + 1;
for (unsigned pass = 0; pass < net->peer_count && required; pass++) {
struct stream_peer *best = NULL; uint64_t best_rate = 0;
for (struct stream_peer *p = net->peers; p; p = p->next) {
if (p->pressure.active || p->cooling) continue;
uint64_t total = 0;
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next)
if (!f->outgoing && f->info.state == STREAM_RECEIVE_ACTIVE) total += flow_rate(f, now);
if (total > best_rate) { best = p; best_rate = total; }
}
if (!best) break;
uint64_t cut = required < best_rate ? required : best_rate;
if (!pressure_begin(best, cut, now)) break;
required -= cut;
}
}
for (struct stream_peer *p = net->peers; p; p = p->next) {
p->busy++;
if (!net->global_pressure && p->load.snapshot.confirmed && !p->pressure.active && !p->cooling) {
uint64_t g = p->load.snapshot.growth_rate;
pressure_begin(p, g ? g + g / 10 + 1 : p->load.queued.bytes / 2 + 1, now);
}
if (p->pressure.active && now >= p->pressure.deadline_ms) {
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream OVERLOAD deadline peer=%llx id=%llu released=%llu required=%llu",
(unsigned long long)p->node_id, (unsigned long long)p->pressure.id,
(unsigned long long)p->pressure.released_rate, (unsigned long long)p->pressure.required_rate);
for (unsigned i = 0; i < p->pressure.count && p->pressure.released_rate < p->pressure.required_rate; i++) {
struct STREAM_RECEIVE *f = flow_by_handle(p, p->pressure.cuts[i].handle, 0);
if (f) flow_close(f, STREAM_REASON_OVERLOAD, 1);
}
}
if (p->pressure.active && (p->pressure.released_rate >= p->pressure.required_rate || now >= p->pressure.deadline_ms)) {
p->pressure.active = 0; p->cooling = 1;
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "stream OVERLOAD complete peer=%llx id=%llu closed=%u rate=%llu requested=%llu",
(unsigned long long)p->node_id, (unsigned long long)p->pressure.id, p->pressure.released_count,
(unsigned long long)p->pressure.released_rate, (unsigned long long)p->pressure.required_rate);
}
pressure_send(p, now); pressure_select(p, now);
if (p->requested.active && now >= p->requested.deadline_ms) p->requested.active = 0;
if (p->cooling) {
if (p->load.snapshot.pressure) p->clear_since_ms = 0;
else if (!p->clear_since_ms) p->clear_since_ms = now;
else if (now - p->clear_since_ms >= STREAM_LOAD_CONFIRM_MS) { p->cooling = 0; p->clear_since_ms = 0; }
}
for (struct STREAM_RECEIVE *f = p->flows; f; f = f->next) {
if (f->account_failed) flow_close(f, STREAM_REASON_PROTOCOL, 1);
if (!f->outgoing && f->info.state == STREAM_RECEIVE_ACTIVE && p->pressure.active
&& flow_age(f, now) > STREAM_LOAD_MAX_AGE_MS) expire_pending(f);
}
p->busy--; peer_sweep(p);
}
}
int stream_peer_get_load(struct UTUN_INSTANCE *inst, uint64_t node, struct stream_peer_load_info *info) {
struct stream_network *net = stream_network_get(inst); struct stream_peer *p = net ? peer_find(net, node) : NULL;
if (!p || !info) { DEBUG_WARN(DEBUG_CATEGORY_STREAM, "stream load unavailable peer=%llx", (unsigned long long)node); return STREAM_ERR_STATE; }
struct stream_peer_load_info result = {.load = p->load.snapshot, .request_id = p->pressure.id,
.required_rate = p->pressure.required_rate, .released_rate = p->pressure.released_rate,
.deadline_ms = p->pressure.deadline_ms, .required_count = p->pressure.required_count, .released_count = p->pressure.released_count,
.request_active = p->pressure.active, .cpu_percent = net->cpu.valid ? net->cpu.average_percent : 0,
.callback_late_ms = net->callback_late_ms, .global_pressure = net->global_pressure};
result.load.queued = p->load.queued; result.load.arrivals = p->load.arrivals; result.load.sent = p->load.sent;
result.load.removed = p->load.removed; result.load.rejected = p->load.rejected;
struct ETCP_CONN *conn = node_conn_direct_get_conn(p->ncd);
if (conn) {
struct ll_queue *queues[] = {conn->send_input_q, conn->input_queue, conn->input_send_q};
for (unsigned i = 0; i < 3; i++) if (queues[i]) {
result.transport_queued_packets += queues[i]->count; result.transport_queued_bytes += queues[i]->total_bytes;
}
result.inflight_bytes = conn->unacked_bytes;
}
*info = result; return STREAM_OK;
}