mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
fix failed tests due to gcsafe
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2567,11 +2567,11 @@ when not defined(JS): #and not defined(NimrodVM):
|
||||
include "system/assign"
|
||||
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.
|
||||
result = currException
|
||||
|
||||
proc getCurrentExceptionMsg*(): string {.inline.} =
|
||||
proc getCurrentExceptionMsg*(): string {.inline, gcsafe.} =
|
||||
## retrieves the error message that was attached to the current
|
||||
## exception; if there is none, "" is returned.
|
||||
var e = getCurrentException()
|
||||
|
||||
@@ -38,11 +38,11 @@ proc chckRangeF(x, a, b: float): float {.inline, compilerproc, gcsafe.}
|
||||
proc chckNil(p: pointer) {.noinline, compilerproc, gcsafe.}
|
||||
|
||||
var
|
||||
framePtr {.rtlThreadVar.}: PFrame
|
||||
excHandler {.rtlThreadVar.}: PSafePoint
|
||||
framePtr {.threadvar.}: PFrame
|
||||
excHandler {.threadvar.}: PSafePoint
|
||||
# list of exception handlers
|
||||
# a global variable for the root of all try blocks
|
||||
currException {.rtlThreadVar.}: ref E_Base
|
||||
currException {.threadvar.}: ref E_Base
|
||||
|
||||
proc popFrame {.compilerRtl, inl.} =
|
||||
framePtr = framePtr.prev
|
||||
|
||||
@@ -28,11 +28,13 @@ proc serve() {.async.} =
|
||||
await processClient(fut)
|
||||
|
||||
when isMainModule:
|
||||
var fut = serve()
|
||||
fut.callback =
|
||||
proc () =
|
||||
if fut.failed:
|
||||
# This test ensures that this exception crashes the application
|
||||
# as it is not handled.
|
||||
raise fut.error
|
||||
runForever()
|
||||
proc main =
|
||||
var fut = serve()
|
||||
fut.callback =
|
||||
proc () =
|
||||
if fut.failed:
|
||||
# This test ensures that this exception crashes the application
|
||||
# as it is not handled.
|
||||
raise fut.error
|
||||
runForever()
|
||||
main()
|
||||
|
||||
@@ -5,7 +5,8 @@ discard """
|
||||
"""
|
||||
import sockets, asyncio, strutils, times
|
||||
|
||||
var disp = newDispatcher()
|
||||
var disp {.threadvar.}: PDispatcher
|
||||
disp = newDispatcher()
|
||||
var msgCount = 0
|
||||
|
||||
when defined(ssl):
|
||||
|
||||
Reference in New Issue
Block a user