fix failed tests due to gcsafe
This commit is contained in:
parent
d1300de5e6
commit
4d863ebb5e
7 changed files with 55 additions and 50 deletions
|
|
@ -588,39 +588,40 @@ proc register*(d: PDispatcher, ftp: PAsyncFTPClient): PDelegate {.discardable.}
|
||||||
return ftp.disp.register(ftp.asyncCSock)
|
return ftp.disp.register(ftp.asyncCSock)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var d = newDispatcher()
|
proc main =
|
||||||
let hev =
|
var d = newDispatcher()
|
||||||
proc (ftp: PAsyncFTPClient, event: TFTPEvent) =
|
let hev =
|
||||||
case event.typ
|
proc (ftp: PAsyncFTPClient, event: TFTPEvent) =
|
||||||
of EvStore:
|
case event.typ
|
||||||
echo("Upload finished!")
|
of EvStore:
|
||||||
ftp.retrFile("payload.JPG", "payload2.JPG", async = true)
|
echo("Upload finished!")
|
||||||
of EvTransferProgress:
|
ftp.retrFile("payload.JPG", "payload2.JPG", async = true)
|
||||||
var time: int64 = -1
|
of EvTransferProgress:
|
||||||
if event.speed != 0:
|
var time: int64 = -1
|
||||||
time = (event.bytesTotal - event.bytesFinished) div event.speed
|
if event.speed != 0:
|
||||||
echo(event.currentJob)
|
time = (event.bytesTotal - event.bytesFinished) div event.speed
|
||||||
echo(event.speed div 1000, " kb/s. - ",
|
echo(event.currentJob)
|
||||||
event.bytesFinished, "/", event.bytesTotal,
|
echo(event.speed div 1000, " kb/s. - ",
|
||||||
" - ", time, " seconds")
|
event.bytesFinished, "/", event.bytesTotal,
|
||||||
echo(d.len)
|
" - ", time, " seconds")
|
||||||
of EvRetr:
|
echo(d.len)
|
||||||
echo("Download finished!")
|
of EvRetr:
|
||||||
ftp.close()
|
echo("Download finished!")
|
||||||
echo d.len
|
ftp.close()
|
||||||
else: assert(false)
|
echo d.len
|
||||||
var ftp = asyncFTPClient("picheta.me", user = "test", pass = "asf", handleEvent = hev)
|
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
|
|
||||||
|
|
||||||
|
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:
|
when isMainModule and false:
|
||||||
var ftp = ftpClient("picheta.me", user = "asdasd", pass = "asfwq")
|
var ftp = ftpClient("picheta.me", user = "asdasd", pass = "asfwq")
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ proc newRope(data: string): PRope =
|
||||||
result.data = data
|
result.data = data
|
||||||
|
|
||||||
var
|
var
|
||||||
cache: PRope # the root of the cache tree
|
cache {.threadvar.}: PRope # the root of the cache tree
|
||||||
N: PRope # dummy rope needed for splay algorithm
|
N {.threadvar.}: PRope # dummy rope needed for splay algorithm
|
||||||
|
|
||||||
when countCacheMisses:
|
when countCacheMisses:
|
||||||
var misses, hits: int
|
var misses, hits: int
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ proc getFormatArg(p: var TFormatParser, a: openArray[string]): int =
|
||||||
if result >=% a.len: raiseInvalidFormat("index out of bounds: " & $result)
|
if result >=% a.len: raiseInvalidFormat("index out of bounds: " & $result)
|
||||||
p.i = i
|
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.} =
|
proc emitChar(p: var TFormatParser, x: var string, ch: char) {.inline.} =
|
||||||
x.add(ch)
|
x.add(ch)
|
||||||
|
|
|
||||||
|
|
@ -2567,11 +2567,11 @@ when not defined(JS): #and not defined(NimrodVM):
|
||||||
include "system/assign"
|
include "system/assign"
|
||||||
include "system/repr"
|
include "system/repr"
|
||||||
|
|
||||||
proc getCurrentException*(): ref E_Base {.compilerRtl, inl.} =
|
proc getCurrentException*(): ref E_Base {.compilerRtl, inl, gcsafe.} =
|
||||||
## retrieves the current exception; if there is none, nil is returned.
|
## retrieves the current exception; if there is none, nil is returned.
|
||||||
result = currException
|
result = currException
|
||||||
|
|
||||||
proc getCurrentExceptionMsg*(): string {.inline.} =
|
proc getCurrentExceptionMsg*(): string {.inline, gcsafe.} =
|
||||||
## retrieves the error message that was attached to the current
|
## retrieves the error message that was attached to the current
|
||||||
## exception; if there is none, "" is returned.
|
## exception; if there is none, "" is returned.
|
||||||
var e = getCurrentException()
|
var e = getCurrentException()
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ proc chckRangeF(x, a, b: float): float {.inline, compilerproc, gcsafe.}
|
||||||
proc chckNil(p: pointer) {.noinline, compilerproc, gcsafe.}
|
proc chckNil(p: pointer) {.noinline, compilerproc, gcsafe.}
|
||||||
|
|
||||||
var
|
var
|
||||||
framePtr {.rtlThreadVar.}: PFrame
|
framePtr {.threadvar.}: PFrame
|
||||||
excHandler {.rtlThreadVar.}: PSafePoint
|
excHandler {.threadvar.}: PSafePoint
|
||||||
# list of exception handlers
|
# list of exception handlers
|
||||||
# a global variable for the root of all try blocks
|
# a global variable for the root of all try blocks
|
||||||
currException {.rtlThreadVar.}: ref E_Base
|
currException {.threadvar.}: ref E_Base
|
||||||
|
|
||||||
proc popFrame {.compilerRtl, inl.} =
|
proc popFrame {.compilerRtl, inl.} =
|
||||||
framePtr = framePtr.prev
|
framePtr = framePtr.prev
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,13 @@ proc serve() {.async.} =
|
||||||
await processClient(fut)
|
await processClient(fut)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var fut = serve()
|
proc main =
|
||||||
fut.callback =
|
var fut = serve()
|
||||||
proc () =
|
fut.callback =
|
||||||
if fut.failed:
|
proc () =
|
||||||
# This test ensures that this exception crashes the application
|
if fut.failed:
|
||||||
# as it is not handled.
|
# This test ensures that this exception crashes the application
|
||||||
raise fut.error
|
# as it is not handled.
|
||||||
runForever()
|
raise fut.error
|
||||||
|
runForever()
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ discard """
|
||||||
"""
|
"""
|
||||||
import sockets, asyncio, strutils, times
|
import sockets, asyncio, strutils, times
|
||||||
|
|
||||||
var disp = newDispatcher()
|
var disp {.threadvar.}: PDispatcher
|
||||||
|
disp = newDispatcher()
|
||||||
var msgCount = 0
|
var msgCount = 0
|
||||||
|
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue