diff --git a/chronos.nimble b/chronos.nimble index 43544417..68e4d97f 100644 --- a/chronos.nimble +++ b/chronos.nimble @@ -1,5 +1,5 @@ packageName = "chronos" -version = "2.3.2" +version = "2.3.3" author = "Status Research & Development GmbH" description = "Chronos" license = "Apache License 2.0 or MIT" diff --git a/chronos/asyncsync.nim b/chronos/asyncsync.nim index c9c6fa8a..3ba65a19 100644 --- a/chronos/asyncsync.nim +++ b/chronos/asyncsync.nim @@ -243,7 +243,6 @@ proc addFirstNoWait*[T](aq: AsyncQueue[T], item: T) = ## Put an item ``item`` to the beginning of the queue ``aq`` immediately. ## ## If queue ``aq`` is full, then ``AsyncQueueFullError`` exception raised. - var w: Future[void] if aq.full(): raise newException(AsyncQueueFullError, "AsyncQueue is full!") aq.queue.addFirst(item) @@ -253,7 +252,6 @@ proc addLastNoWait*[T](aq: AsyncQueue[T], item: T) = ## Put an item ``item`` at the end of the queue ``aq`` immediately. ## ## If queue ``aq`` is full, then ``AsyncQueueFullError`` exception raised. - var w: Future[void] if aq.full(): raise newException(AsyncQueueFullError, "AsyncQueue is full!") aq.queue.addLast(item) @@ -263,7 +261,6 @@ proc popFirstNoWait*[T](aq: AsyncQueue[T]): T = ## Get an item from the beginning of the queue ``aq`` immediately. ## ## If queue ``aq`` is empty, then ``AsyncQueueEmptyError`` exception raised. - var w: Future[void] if aq.empty(): raise newException(AsyncQueueEmptyError, "AsyncQueue is empty!") result = aq.queue.popFirst() @@ -273,7 +270,6 @@ proc popLastNoWait*[T](aq: AsyncQueue[T]): T = ## Get an item from the end of the queue ``aq`` immediately. ## ## If queue ``aq`` is empty, then ``AsyncQueueEmptyError`` exception raised. - var w: Future[void] if aq.empty(): raise newException(AsyncQueueEmptyError, "AsyncQueue is empty!") result = aq.queue.popLast() diff --git a/chronos/timer.nim b/chronos/timer.nim index bc8a25fe..c61ff6d4 100644 --- a/chronos/timer.nim +++ b/chronos/timer.nim @@ -25,8 +25,6 @@ const asyncTimer* {.strdefine.} = "mono" when defined(windows): - from winlean import DWORD - when asyncTimer == "system": from winlean import getSystemTimeAsFileTime, FILETIME diff --git a/chronos/transports/stream.nim b/chronos/transports/stream.nim index 3348d0f2..4a2982e9 100644 --- a/chronos/transports/stream.nim +++ b/chronos/transports/stream.nim @@ -7,7 +7,7 @@ # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) import net, nativesockets, os, deques -import ../asyncloop, ../handles, ../sendfile +import ../asyncloop, ../handles import common {.deadCodeElim: on.} @@ -972,6 +972,7 @@ when defined(windows): server.aovl.data.cb(addr server.aovl) else: + import ../sendfile template initBufferStreamVector(v, p, n, t: untyped) = (v).kind = DataBuffer @@ -1601,7 +1602,7 @@ proc createStreamServer*[T](host: TransportAddress, init: TransportInitCallback = nil): StreamServer = var fflags = flags + {GCUserData} GC_ref(udata) - result = createStreamServer(host, cbproc, flags, sock, backlog, bufferSize, + result = createStreamServer(host, cbproc, fflags, sock, backlog, bufferSize, child, init, cast[pointer](udata)) proc getUserData*[T](server: StreamServer): T {.inline.} = diff --git a/tests/config.nims b/tests/config.nims index 580be36a..fabd2ff1 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -1,4 +1,4 @@ -switch("hints", "off") -switch("verbosity", "0") -switch("threads", "on") +# switch("hints", "off") +# switch("verbosity", "0") +# switch("threads", "on") diff --git a/tests/testaddress.nim b/tests/testaddress.nim index a2a2e367..5348e727 100644 --- a/tests/testaddress.nim +++ b/tests/testaddress.nim @@ -111,7 +111,7 @@ suite "TransportAddress test suite": var errcounter = 0 for item in tests: try: - var ta = initTAddress(item) + discard initTAddress(item) except TransportAddressError: inc(errcounter) check errcounter == len(tests) @@ -126,7 +126,7 @@ suite "TransportAddress test suite": var errcounter = 0 for item in tests: try: - var ta = initTAddress(item, Port(443)) + discard initTAddress(item, Port(443)) except TransportAddressError: inc(errcounter) check errcounter == len(tests) @@ -134,7 +134,7 @@ suite "TransportAddress test suite": test "Faulty initTAddress(string, Port)": var errcounter = 0 try: - var ta = initTAddress("127.0.0.1", 100000) + discard initTAddress("127.0.0.1", 100000) except TransportAddressError: inc(errcounter) check errcounter == 1 @@ -151,7 +151,7 @@ suite "TransportAddress test suite": var errcounter = 0 for item in numeric: try: - var taseq = resolveTAddress(item) + discard resolveTAddress(item) except TransportAddressError: inc(errcounter) check errcounter == len(numeric) @@ -168,7 +168,7 @@ suite "TransportAddress test suite": var errcounter = 0 for item in numeric: try: - var taseq = resolveTAddress(item, Port(443)) + discard resolveTAddress(item, Port(443)) except TransportAddressError: inc(errcounter) check errcounter == len(numeric) diff --git a/tests/testasyncstream.nim b/tests/testasyncstream.nim index 54869d16..fa43637d 100644 --- a/tests/testasyncstream.nim +++ b/tests/testasyncstream.nim @@ -547,7 +547,8 @@ suite "ChunkedStream test suite": var rstream2 = newChunkedStreamReader(rstream) try: var r = await rstream2.read() - except AsyncStreamReadError as e: + doAssert(len(r) > 0) + except AsyncStreamReadError: res = true await rstream2.closeWait() await rstream.closeWait() diff --git a/tests/testdatagram.nim b/tests/testdatagram.nim index 3cde640b..58e739be 100644 --- a/tests/testdatagram.nim +++ b/tests/testdatagram.nim @@ -453,7 +453,6 @@ suite "Datagram Transport test suite": proc testTransportClose(): Future[bool] {.async.} = var ta = initTAddress("127.0.0.1:45000") - var counter = 0 proc clientMark(transp: DatagramTransport, raddr: TransportAddress): Future[void] {.async.} = discard diff --git a/tests/testfut.nim b/tests/testfut.nim index d0725b24..234754a6 100644 --- a/tests/testfut.nim +++ b/tests/testfut.nim @@ -27,7 +27,7 @@ suite "Future[T] behavior test suite": ## Test for not immediately completed future and timeout = -1 result = 0 try: - var res = await wait(testFuture1(), InfiniteDuration) + discard await wait(testFuture1(), InfiniteDuration) result = 1 except: result = 0 @@ -38,7 +38,7 @@ suite "Future[T] behavior test suite": ## Test for immediately completed future and timeout = -1 result = 0 try: - var res = await wait(testFuture2(), InfiniteDuration) + discard await wait(testFuture2(), InfiniteDuration) result = 2 except: result = 0 @@ -49,7 +49,7 @@ suite "Future[T] behavior test suite": ## Test for not immediately completed future and timeout = 0 result = 0 try: - var res = await wait(testFuture1(), 0.milliseconds) + discard await wait(testFuture1(), 0.milliseconds) except AsyncTimeoutError: result = 3 @@ -59,7 +59,7 @@ suite "Future[T] behavior test suite": ## Test for immediately completed future and timeout = 0 result = 0 try: - var res = await wait(testFuture2(), 0.milliseconds) + discard await wait(testFuture2(), 0.milliseconds) result = 4 except: result = 0 @@ -70,7 +70,7 @@ suite "Future[T] behavior test suite": ## Test for future which cannot be completed in timeout period result = 0 try: - var res = await wait(testFuture100(), 50.milliseconds) + discard await wait(testFuture100(), 50.milliseconds) except AsyncTimeoutError: result = 5 @@ -79,7 +79,7 @@ suite "Future[T] behavior test suite": ## Test for future which will be completed before timeout exceeded. try: - var res = await wait(testFuture100(), 500.milliseconds) + discard await wait(testFuture100(), 500.milliseconds) result = 6 except: result = -6 diff --git a/tests/testmacro.nim b/tests/testmacro.nim index 19e8e498..fc9ca196 100644 --- a/tests/testmacro.nim +++ b/tests/testmacro.nim @@ -43,7 +43,7 @@ proc testAwait(): Future[bool] {.async.} = discard res = 0 try: - var res = await asyncRetExceptionValue(100) + discard await asyncRetExceptionValue(100) return false except ValueError: discard @@ -68,7 +68,7 @@ proc testAwaitne(): Future[bool] {.async.} = res2 = awaitne asyncRetExceptionValue(100) try: - var res = res2.read() + discard res2.read() return false except ValueError: discard diff --git a/tests/testserver.nim b/tests/testserver.nim index 890208d1..a72346d3 100644 --- a/tests/testserver.nim +++ b/tests/testserver.nim @@ -90,6 +90,7 @@ suite "Server's test suite": var msg = "TEST\r\n" discard await transp.write(msg) var line = await transp.readLine() + doAssert(len(line) > 0) transp.close() server.stop() server.close() @@ -115,6 +116,7 @@ suite "Server's test suite": var pserver = createStreamServer(ta, serveCustomStreamClient, {ReuseAddr}, child = cast[StreamServer](server), init = customServerTransport) + doAssert(not isNil(pserver)) waitFor client1(server, ta) result = (server.test1 == "CONNECTION") and (server.test2 == "CUSTOM") diff --git a/tests/testsignal.nim b/tests/testsignal.nim index b8605568..027f6193 100644 --- a/tests/testsignal.nim +++ b/tests/testsignal.nim @@ -5,7 +5,7 @@ # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) -import unittest, strutils +import unittest import ../chronos when defined(nimHasUsed): {.used.} diff --git a/tests/teststream.nim b/tests/teststream.nim index 6c1bbc3c..b144afe3 100644 --- a/tests/teststream.nim +++ b/tests/teststream.nim @@ -280,6 +280,7 @@ suite "Stream Transport test suite": var res = await transp.write(data) doAssert(res == len(data)) var res = await transp.write(crlf) + doAssert(res == len(crlf)) var line = await transp.readLine() doAssert(line == "DONE") result = 1 @@ -294,6 +295,7 @@ suite "Stream Transport test suite": var res = await transp.write(data) doAssert(res == len(data)) var res = await transp.write(crlf) + doAssert(res == len(crlf)) var line = await transp.readLine() doAssert(line == "DONE") result = 1 @@ -313,7 +315,6 @@ suite "Stream Transport test suite": proc swarmManager1(address: TransportAddress): Future[int] {.async.} = var workers = newSeq[Future[int]](ClientsCount) - var count = ClientsCount for i in 0..