mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-09 09:53:27 +00:00
Fix one more place of assertion for high concurrency requests. (#277)
This commit is contained in:
parent
c5894bae1b
commit
728ab7faa7
@ -274,6 +274,13 @@ proc setupHttpClientResponseTracker(): HttpClientTracker {.gcsafe.} =
|
|||||||
addTracker(HttpClientResponseTrackerName, res)
|
addTracker(HttpClientResponseTrackerName, res)
|
||||||
res
|
res
|
||||||
|
|
||||||
|
template checkClosed(reqresp: untyped): untyped =
|
||||||
|
if reqresp.connection.state in {HttpClientConnectionState.Closing,
|
||||||
|
HttpClientConnectionState.Closed}:
|
||||||
|
let e = newHttpUseClosedError()
|
||||||
|
reqresp.setError(e)
|
||||||
|
raise e
|
||||||
|
|
||||||
proc new*(t: typedesc[HttpSessionRef],
|
proc new*(t: typedesc[HttpSessionRef],
|
||||||
flags: HttpClientFlags = {},
|
flags: HttpClientFlags = {},
|
||||||
maxRedirections = HttpMaxRedirections,
|
maxRedirections = HttpMaxRedirections,
|
||||||
@ -1073,11 +1080,7 @@ proc finish*(request: HttpClientRequestRef): Future[HttpClientResponseRef] {.
|
|||||||
## Finish sending request and receive response.
|
## Finish sending request and receive response.
|
||||||
doAssert(not(isNil(request.connection)),
|
doAssert(not(isNil(request.connection)),
|
||||||
"Request missing connection instance")
|
"Request missing connection instance")
|
||||||
if request.connection.state in {HttpClientConnectionState.Closing,
|
request.checkClosed()
|
||||||
HttpClientConnectionState.Closed}:
|
|
||||||
let e = newHttpUseClosedError()
|
|
||||||
request.setError(e)
|
|
||||||
raise e
|
|
||||||
doAssert(request.state == HttpReqRespState.Open,
|
doAssert(request.state == HttpReqRespState.Open,
|
||||||
"Request's state is " & $request.state)
|
"Request's state is " & $request.state)
|
||||||
doAssert(request.connection.state ==
|
doAssert(request.connection.state ==
|
||||||
@ -1145,6 +1148,7 @@ proc finish*(response: HttpClientResponseRef) {.async.} =
|
|||||||
if response.state == HttpReqRespState.Open:
|
if response.state == HttpReqRespState.Open:
|
||||||
doAssert(not(isNil(response.connection)),
|
doAssert(not(isNil(response.connection)),
|
||||||
"Response missing connection instance")
|
"Response missing connection instance")
|
||||||
|
response.checkClosed()
|
||||||
doAssert(response.connection.state ==
|
doAssert(response.connection.state ==
|
||||||
HttpClientConnectionState.ResponseBodyReceiving,
|
HttpClientConnectionState.ResponseBodyReceiving,
|
||||||
"Connection state is " & $response.connection.state)
|
"Connection state is " & $response.connection.state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user