fix failed tests due to gcsafe

This commit is contained in:
Araq 2014-08-12 10:11:58 +02:00
commit 4d863ebb5e
7 changed files with 55 additions and 50 deletions

View file

@ -588,39 +588,40 @@ proc register*(d: PDispatcher, ftp: PAsyncFTPClient): PDelegate {.discardable.}
return ftp.disp.register(ftp.asyncCSock)
when isMainModule:
var d = newDispatcher()
let hev =
proc (ftp: PAsyncFTPClient, event: TFTPEvent) =
case event.typ
of EvStore:
echo("Upload finished!")
ftp.retrFile("payload.JPG", "payload2.JPG", async = true)
of EvTransferProgress:
var time: int64 = -1
if event.speed != 0:
time = (event.bytesTotal - event.bytesFinished) div event.speed
echo(event.currentJob)
echo(event.speed div 1000, " kb/s. - ",
event.bytesFinished, "/", event.bytesTotal,
" - ", time, " seconds")
echo(d.len)
of EvRetr:
echo("Download finished!")
ftp.close()
echo d.len
else: assert(false)
var ftp = asyncFTPClient("picheta.me", user = "test", pass = "asf", handleEvent = hev)
d.register(ftp)
d.len.echo()
ftp.connect()
echo "connected"
ftp.store("payload.JPG", "payload.JPG", async = true)
d.len.echo()
echo "uploading..."
while true:
if not d.poll(): break
proc main =
var d = newDispatcher()
let hev =
proc (ftp: PAsyncFTPClient, event: TFTPEvent) =
case event.typ
of EvStore:
echo("Upload finished!")
ftp.retrFile("payload.JPG", "payload2.JPG", async = true)
of EvTransferProgress:
var time: int64 = -1
if event.speed != 0:
time = (event.bytesTotal - event.bytesFinished) div event.speed
echo(event.currentJob)
echo(event.speed div 1000, " kb/s. - ",
event.bytesFinished, "/", event.bytesTotal,
" - ", time, " seconds")
echo(d.len)
of EvRetr:
echo("Download finished!")
ftp.close()
echo d.len
else: assert(false)
var ftp = asyncFTPClient("picheta.me", user = "test", pass = "asf", handleEvent = hev)
d.register(ftp)
d.len.echo()
ftp.connect()
echo "connected"
ftp.store("payload.JPG", "payload.JPG", async = true)
d.len.echo()
echo "uploading..."
while true:
if not d.poll(): break
main()
when isMainModule and false:
var ftp = ftpClient("picheta.me", user = "asdasd", pass = "asfwq")

View file

@ -58,8 +58,8 @@ proc newRope(data: string): PRope =
result.data = data
var
cache: PRope # the root of the cache tree
N: PRope # dummy rope needed for splay algorithm
cache {.threadvar.}: PRope # the root of the cache tree
N {.threadvar.}: PRope # dummy rope needed for splay algorithm
when countCacheMisses:
var misses, hits: int

View file

@ -84,7 +84,8 @@ proc getFormatArg(p: var TFormatParser, a: openArray[string]): int =
if result >=% a.len: raiseInvalidFormat("index out of bounds: " & $result)
p.i = i
proc scanDollar(p: var TFormatParser, a: openarray[string], s: var string)
proc scanDollar(p: var TFormatParser, a: openarray[string], s: var string) {.
noSideEffect.}
proc emitChar(p: var TFormatParser, x: var string, ch: char) {.inline.} =
x.add(ch)