reqPing makes code not gcsafe, fails to compile
Closed this issue · 1 comments
luked99 commented
If I try to compile a simple example which uses readData() using nim 0.17.2, it fails with:
Error: type mismatch: got (AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.})
but expected one of:
proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void]; address = ""): Future[void]
The problem seems to be the use of reqPing, which is a global variable and makes the async function not thread safe.
Here's the code I'm using (call to verifyWebsocketRequest() omitted for clarity).
var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
var f = await req.client.readData(false)
echo $f
waitfor server.serve(Port(8080), cb)
Araq commented
Was fixed by your PR.