Skip to content

Commit

Permalink
dbconn fix nph issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Sep 4, 2024
1 parent 06a9b01 commit 9327ec1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions waku/common/databases/db_postgres/dbconn.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import
std/[times, strutils, asyncnet, os, sequtils, oserrors],
results,
chronos
import std/[times, strutils, asyncnet, os, sequtils], results, chronos

include db_connector/db_postgres

Expand Down Expand Up @@ -36,13 +33,13 @@ proc open*(connString: string): Result[DbConn, string] =

return err("unknown reason")

let asyncFd = cast[asyncengine.AsyncFD](pqsocket(conn))
asyncengine.register(asyncFd) ## registering the socket fd in chronos for better wait for data
## registering the socket fd in chronos for better wait for data
let asyncFd: asyncengine.AsyncFD = pqsocket(conn)
asyncengine.register(asyncFd)

return ok(conn)

proc closeDbConn*(
db: DbConn
) {.raises: [OSError].} =
proc closeDbConn*(db: DbConn) {.raises: [OSError].} =
let fd = db.pqsocket()
if fd != -1:
asyncengine.unregister(cast[asyncengine.AsyncFD](fd))
Expand Down

0 comments on commit 9327ec1

Please sign in to comment.