mirror of
https://github.com/cjdelisle/cjdns
synced 2025-10-05 16:22:54 +02:00
SwitchPinger: Do not include additional data during a timeout because it will include stale data from previous requests
This commit is contained in:
@@ -263,18 +263,20 @@ static void onPingResponse(String* data, uint32_t milliseconds, void* vping)
|
||||
uint32_t version = p->context->incomingVersion;
|
||||
struct SwitchPinger_Response* resp =
|
||||
Allocator_calloc(p->pub.pingAlloc, sizeof(struct SwitchPinger_Response), 1);
|
||||
resp->version = p->context->incomingVersion;
|
||||
resp->res = err;
|
||||
resp->label = label;
|
||||
resp->data = data;
|
||||
resp->milliseconds = milliseconds;
|
||||
resp->version = version;
|
||||
Bits_memcpy(resp->key, p->context->incomingKey, 32);
|
||||
Bits_memcpy(&resp->snode, &p->context->incomingSnodeAddr, sizeof(struct Address));
|
||||
resp->kbpsLimit = p->context->incomingSnodeKbps;
|
||||
resp->rpath = p->context->rpath;
|
||||
resp->ping = &p->pub;
|
||||
Bits_memcpy(&resp->lladdr, &p->context->lladdrMsg, sizeof p->context->lladdrMsg);
|
||||
if (err != SwitchPinger_Result_TIMEOUT) {
|
||||
resp->version = p->context->incomingVersion;
|
||||
resp->data = data;
|
||||
resp->version = version;
|
||||
Bits_memcpy(resp->key, p->context->incomingKey, 32);
|
||||
Bits_memcpy(&resp->snode, &p->context->incomingSnodeAddr, sizeof(struct Address));
|
||||
resp->kbpsLimit = p->context->incomingSnodeKbps;
|
||||
resp->rpath = p->context->rpath;
|
||||
Bits_memcpy(&resp->lladdr, &p->context->lladdrMsg, sizeof p->context->lladdrMsg);
|
||||
}
|
||||
p->onResponse(resp, p->pub.onResponseContext);
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,9 @@ static void adminPingOnResponse(struct SwitchPinger_Response* resp, void* vping)
|
||||
Dict_putStringC(rd, "responsePath", pathStr, pingAlloc);
|
||||
}
|
||||
|
||||
Dict_putIntC(rd, "version", resp->version, pingAlloc);
|
||||
if (resp->version) {
|
||||
Dict_putIntC(rd, "version", resp->version, pingAlloc);
|
||||
}
|
||||
Dict_putIntC(rd, "ms", resp->milliseconds, pingAlloc);
|
||||
Dict_putStringC(rd, "result", SwitchPinger_resultString(resp->res), pingAlloc);
|
||||
Dict_putStringC(rd, "path", ping->path, pingAlloc);
|
||||
|
Reference in New Issue
Block a user