fix deprecations and other warnings (#13748)
This commit is contained in:
parent
182d3c16e3
commit
5b55aa52d0
22 changed files with 63 additions and 66 deletions
|
|
@ -6,11 +6,10 @@ discard """
|
|||
|
||||
import asyncdispatch
|
||||
import asyncfile
|
||||
import times
|
||||
|
||||
var asyncStdout = 1.AsyncFD.newAsyncFile()
|
||||
proc doStuff: Future[void] {.async.} =
|
||||
await asyncStdout.write "hello world\n"
|
||||
|
||||
let fut = doStuff()
|
||||
doAssert fut.finished, "Poll is needed unnecessarily. See #6846."
|
||||
doAssert fut.finished, "Poll is needed unnecessarily. See #6846."
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import asyncdispatch, net, os, nativesockets
|
|||
# bug: https://github.com/nim-lang/Nim/issues/5279
|
||||
|
||||
proc setupServerSocket(hostname: string, port: Port): AsyncFD =
|
||||
let fd = newNativeSocket()
|
||||
let fd = createNativeSocket()
|
||||
if fd == osInvalidSocket:
|
||||
raiseOSError(osLastError())
|
||||
setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
|
||||
|
|
@ -30,7 +30,7 @@ for i in 0..100:
|
|||
if not fut.failed:
|
||||
fut.read().closeSocket()
|
||||
|
||||
var fd = newAsyncNativeSocket()
|
||||
var fd = createAsyncNativeSocket()
|
||||
waitFor fd.connect("localhost", port)
|
||||
serverFd.closeSocket()
|
||||
fd.closeSocket()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ when defined(windows) or defined(nimdoc):
|
|||
quit("Error: unhandled exception: Connection refused")
|
||||
else:
|
||||
proc testAsyncConnect() {.async.} =
|
||||
var s = newAsyncNativeSocket()
|
||||
var s = createAsyncNativeSocket()
|
||||
|
||||
await s.connect(testHost, testPort)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ proc setupServerSocket(hostname: string, port: Port, domain: Domain): AsyncFD =
|
|||
## Creates a socket, binds it to the specified address, and starts listening for connections.
|
||||
## Registers the descriptor with the dispatcher of the current thread
|
||||
## Raises OSError in case of an error.
|
||||
let fd = newNativeSocket(domain)
|
||||
let fd = createNativeSocket(domain)
|
||||
setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
|
||||
var aiList = getAddrInfo(hostname, port, domain)
|
||||
if bindAddr(fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ template processTest(t, x: untyped) =
|
|||
when defined(macosx):
|
||||
echo "All tests passed!"
|
||||
elif not defined(windows):
|
||||
import os, posix, nativesockets, times
|
||||
import os, posix, nativesockets
|
||||
|
||||
when ioselSupportedPlatform:
|
||||
import osproc
|
||||
|
|
@ -445,7 +445,7 @@ elif not defined(windows):
|
|||
var
|
||||
thr: array[0..7, Thread[SelectEvent]]
|
||||
var selector = newSelector[int]()
|
||||
var sock = newNativeSocket()
|
||||
var sock = createNativeSocket()
|
||||
var event = newSelectEvent()
|
||||
for i in 0..high(thr):
|
||||
createThread(thr[i], event_wait_thread, event)
|
||||
|
|
@ -475,7 +475,7 @@ else:
|
|||
|
||||
proc socket_notification_test(): bool =
|
||||
proc create_test_socket(): SocketHandle =
|
||||
var sock = newNativeSocket()
|
||||
var sock = createNativeSocket()
|
||||
setBlocking(sock, false)
|
||||
result = sock
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ proc launchSwarm(name: ptr SockAddr) {.async.} =
|
|||
var saddr = Sockaddr_in()
|
||||
while i < swarmSize:
|
||||
var peeraddr = prepareAddress(INADDR_LOOPBACK, 0)
|
||||
var sock = newAsyncNativeSocket(nativesockets.AF_INET,
|
||||
nativesockets.SOCK_DGRAM,
|
||||
Protocol.IPPROTO_UDP)
|
||||
var sock = createAsyncNativeSocket(nativesockets.AF_INET,
|
||||
nativesockets.SOCK_DGRAM,
|
||||
Protocol.IPPROTO_UDP)
|
||||
if bindAddr(sock.SocketHandle, cast[ptr SockAddr](peeraddr),
|
||||
sizeof(Sockaddr_in).Socklen) < 0'i32:
|
||||
raiseOSError(osLastError())
|
||||
|
|
@ -91,9 +91,9 @@ proc readMessages(server: AsyncFD) {.async.} =
|
|||
|
||||
proc createServer() {.async.} =
|
||||
var name = prepareAddress(INADDR_LOOPBACK, serverPort)
|
||||
var server = newAsyncNativeSocket(nativesockets.AF_INET,
|
||||
nativesockets.SOCK_DGRAM,
|
||||
Protocol.IPPROTO_UDP)
|
||||
var server = createAsyncNativeSocket(nativesockets.AF_INET,
|
||||
nativesockets.SOCK_DGRAM,
|
||||
Protocol.IPPROTO_UDP)
|
||||
if bindAddr(server.SocketHandle, cast[ptr SockAddr](name),
|
||||
sizeof(Sockaddr_in).Socklen) < 0'i32:
|
||||
raiseOSError(osLastError())
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ when defined(windows):
|
|||
|
||||
proc launchSwarm(port: Port) {.async.} =
|
||||
for i in 0 ..< swarmSize:
|
||||
var sock = newNativeSocket()
|
||||
var sock = createNativeSocket()
|
||||
setBlocking(sock, false)
|
||||
|
||||
await winConnect(AsyncFD(sock), "localhost", port)
|
||||
|
|
@ -229,7 +229,7 @@ when defined(windows):
|
|||
doAssert false
|
||||
|
||||
proc createServer(port: Port) {.async.} =
|
||||
var server = newNativeSocket()
|
||||
var server = createNativeSocket()
|
||||
setBlocking(server, false)
|
||||
block:
|
||||
var name = Sockaddr_in()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue