Fix all compilation warnings for 1.0.2.
Fix all related problems.
This commit is contained in:
parent
5f1391f39f
commit
fb00b20cfa
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
const asyncTimer* {.strdefine.} = "mono"
|
||||
|
||||
when defined(windows):
|
||||
from winlean import DWORD
|
||||
|
||||
when asyncTimer == "system":
|
||||
from winlean import getSystemTimeAsFileTime, FILETIME
|
||||
|
||||
|
|
|
@ -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.} =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
switch("hints", "off")
|
||||
switch("verbosity", "0")
|
||||
switch("threads", "on")
|
||||
# switch("hints", "off")
|
||||
# switch("verbosity", "0")
|
||||
# switch("threads", "on")
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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.}
|
||||
|
|
|
@ -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..<ClientsCount:
|
||||
workers[i] = swarmWorker1(address)
|
||||
await waitAll(workers)
|
||||
|
@ -323,7 +324,6 @@ suite "Stream Transport test suite":
|
|||
|
||||
proc swarmManager2(address: TransportAddress): Future[int] {.async.} =
|
||||
var workers = newSeq[Future[int]](ClientsCount)
|
||||
var count = ClientsCount
|
||||
for i in 0..<ClientsCount:
|
||||
workers[i] = swarmWorker2(address)
|
||||
await waitAll(workers)
|
||||
|
@ -333,7 +333,6 @@ suite "Stream Transport test suite":
|
|||
|
||||
proc swarmManager3(address: TransportAddress): Future[int] {.async.} =
|
||||
var workers = newSeq[Future[int]](ClientsCount)
|
||||
var count = ClientsCount
|
||||
for i in 0..<ClientsCount:
|
||||
workers[i] = swarmWorker3(address)
|
||||
await waitAll(workers)
|
||||
|
@ -343,7 +342,6 @@ suite "Stream Transport test suite":
|
|||
|
||||
proc swarmManager4(address: TransportAddress): Future[int] {.async.} =
|
||||
var workers = newSeq[Future[int]](FilesCount)
|
||||
var count = FilesCount
|
||||
for i in 0..<FilesCount:
|
||||
workers[i] = swarmWorker4(address)
|
||||
await waitAll(workers)
|
||||
|
@ -360,7 +358,6 @@ suite "Stream Transport test suite":
|
|||
await server.join()
|
||||
|
||||
proc test2(address: TransportAddress): Future[int] {.async.} =
|
||||
var counter = 0
|
||||
var server = createStreamServer(address, serveClient2, {ReuseAddr})
|
||||
server.start()
|
||||
result = await swarmManager2(address)
|
||||
|
@ -369,7 +366,6 @@ suite "Stream Transport test suite":
|
|||
await server.join()
|
||||
|
||||
proc test3(address: TransportAddress): Future[int] {.async.} =
|
||||
var counter = 0
|
||||
var server = createStreamServer(address, serveClient3, {ReuseAddr})
|
||||
server.start()
|
||||
result = await swarmManager3(address)
|
||||
|
@ -393,13 +389,13 @@ suite "Stream Transport test suite":
|
|||
var data = ConstantMessage
|
||||
for i in 0..<MessagesCount:
|
||||
var res = await transp.write(data)
|
||||
doAssert(res == len(data))
|
||||
result = MessagesCount
|
||||
transp.close()
|
||||
await transp.join()
|
||||
|
||||
proc swarmManager(address: TransportAddress): Future[int] {.async.} =
|
||||
var workers = newSeq[Future[int]](ClientsCount)
|
||||
var count = ClientsCount
|
||||
for i in 0..<ClientsCount:
|
||||
workers[i] = swarmWorker(address)
|
||||
await waitAll(workers)
|
||||
|
@ -448,6 +444,7 @@ suite "Stream Transport test suite":
|
|||
copyMem(addr seqdata[0], addr data[0], len(data))
|
||||
for i in 0..<MessagesCount:
|
||||
var res = await transp.write(seqdata)
|
||||
doAssert(res == len(seqdata))
|
||||
result = MessagesCount
|
||||
transp.close()
|
||||
await transp.join()
|
||||
|
@ -577,6 +574,7 @@ suite "Stream Transport test suite":
|
|||
var transp = await connect(address)
|
||||
try:
|
||||
var res = await transp.readUntil(addr buffer[0], len(buffer), sep)
|
||||
doAssert(res == 0)
|
||||
except TransportIncompleteError:
|
||||
result = 1
|
||||
transp.close()
|
||||
|
@ -640,6 +638,7 @@ suite "Stream Transport test suite":
|
|||
proc testConnectionRefused(address: TransportAddress): Future[bool] {.async.} =
|
||||
try:
|
||||
var transp = await connect(address)
|
||||
doAssert(isNil(transp))
|
||||
except TransportOsError as e:
|
||||
let ecode = int(e.code)
|
||||
when defined(windows):
|
||||
|
|
Loading…
Reference in New Issue