From 8168fcea254e486284b4e48c91d74b76320c0c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Fri, 19 Jul 2019 11:12:25 +0200 Subject: [PATCH] fix some problems raised by Nim 0.20.2 --- json_rpc/client.nim | 9 +++++---- json_rpc/clients/httpclient.nim | 2 +- json_rpc/clients/websocketclient.nim | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/json_rpc/client.nim b/json_rpc/client.nim index 853e7ed..6be99c0 100644 --- a/json_rpc/client.nim +++ b/json_rpc/client.nim @@ -52,7 +52,7 @@ macro checkGet(node: JsonNode, fieldName: string, of JObject: result.add(quote do: `n`.getObject) else: discard -proc processMessage*(self: RpcClient, line: string) = +proc processMessage*(self: RpcClient, line: string) {.gcsafe.} = # Note: this doesn't use any transport code so doesn't need to be # differentiated. let node = parseJson(line) @@ -82,9 +82,10 @@ proc processMessage*(self: RpcClient, line: string) = elif "method" in node: # This could be subscription notification let name = node["method"].getStr() - let handler = self.methodHandlers.getOrDefault(name) - if not handler.isNil: - handler(node{"params"}) + {.gcsafe.}: + let handler = self.methodHandlers.getOrDefault(name) + if not handler.isNil: + handler(node{"params"}) else: raise newException(ValueError, "Invalid jsonrpc message: " & $node) diff --git a/json_rpc/clients/httpclient.nim b/json_rpc/clients/httpclient.nim index ecec4bb..eb90256 100644 --- a/json_rpc/clients/httpclient.nim +++ b/json_rpc/clients/httpclient.nim @@ -172,7 +172,7 @@ proc httpMethod*(client: RpcHttpClient, m: HttpMethod) = client.options.httpMethod = m method call*(client: RpcHttpClient, name: string, - params: JsonNode): Future[Response] {.async.} = + params: JsonNode): Future[Response] {.async, gcsafe.} = ## Remotely calls the specified RPC method. let id = client.getNextId() diff --git a/json_rpc/clients/websocketclient.nim b/json_rpc/clients/websocketclient.nim index ae2fa7d..c1c532e 100644 --- a/json_rpc/clients/websocketclient.nim +++ b/json_rpc/clients/websocketclient.nim @@ -1,4 +1,4 @@ -import ../client, chronos, tables, json +import ../client, chronos, tables, json, strtabs const newsUseChronos = true include news