Merge pull request #96 from codex-storage/reduce-timeouts

Reduce timeouts
This commit is contained in:
Csaba Kiraly 2024-10-03 10:54:44 +02:00 committed by GitHub
commit f121d080e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -128,7 +128,7 @@ const
IpMajorityInterval = 5.minutes ## Interval for checking the latest IP:Port IpMajorityInterval = 5.minutes ## Interval for checking the latest IP:Port
## majority and updating this when SPR auto update is set. ## majority and updating this when SPR auto update is set.
InitialLookups = 1 ## Amount of lookups done when populating the routing table InitialLookups = 1 ## Amount of lookups done when populating the routing table
ResponseTimeout* = 4.seconds ## timeout for the response of a request-response ResponseTimeout* = 1.seconds ## timeout for the response of a request-response
MaxProvidersEntries* = 1_000_000 # one million records MaxProvidersEntries* = 1_000_000 # one million records
MaxProvidersPerEntry* = 20 # providers per entry MaxProvidersPerEntry* = 20 # providers per entry
## call ## call

View File

@ -15,9 +15,9 @@ import
"."/[node, encoding, sessions] "."/[node, encoding, sessions]
const const
handshakeTimeout* = 2.seconds ## timeout for the reply on the handshakeTimeout* = 500.milliseconds ## timeout for the reply on the
## whoareyou message ## whoareyou message
responseTimeout* = 4.seconds ## timeout for the response of a request-response responseTimeout* = 1.seconds ## timeout for the response of a request-response
## call ## call
type type
@ -93,7 +93,7 @@ proc sendMessage*(t: Transport, toNode: Node, message: seq[byte]) =
t.send(toNode, data) t.send(toNode, data)
t.keyexchangeInProgress.incl(toNode.id) t.keyexchangeInProgress.incl(toNode.id)
trace "keyexchangeInProgress added", myport = t.bindAddress.port , dstId = toNode trace "keyexchangeInProgress added", myport = t.bindAddress.port , dstId = toNode
sleepAsync(responseTimeout).addCallback() do(data: pointer): sleepAsync(handshakeTimeout).addCallback() do(data: pointer):
t.keyexchangeInProgress.excl(toNode.id) t.keyexchangeInProgress.excl(toNode.id)
trace "keyexchangeInProgress removed (timeout)", myport = t.bindAddress.port , dstId = toNode trace "keyexchangeInProgress removed (timeout)", myport = t.bindAddress.port , dstId = toNode
else: else:
@ -116,8 +116,7 @@ proc sendWhoareyou(t: Transport, toId: NodeId, a: Address,
let data = encodeWhoareyouPacket(t.rng[], t.codec, toId, a, requestNonce, let data = encodeWhoareyouPacket(t.rng[], t.codec, toId, a, requestNonce,
recordSeq, pubkey) recordSeq, pubkey)
sleepAsync(handshakeTimeout).addCallback() do(data: pointer): sleepAsync(handshakeTimeout).addCallback() do(data: pointer):
# TODO: should we still provide cancellation in case handshake completes # handshake key is popped in decodeHandshakePacket. if not yet popped by timeout:
# correctly?
if t.codec.hasHandshake(key): if t.codec.hasHandshake(key):
debug "Handshake timeout", myport = t.bindAddress.port , dstId = toId, address = a debug "Handshake timeout", myport = t.bindAddress.port , dstId = toId, address = a
t.codec.handshakes.del(key) t.codec.handshakes.del(key)