diff options
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/ioselects/ioselectors_kqueue.nim | 4 | ||||
-rw-r--r-- | lib/pure/net.nim | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/pure/ioselects/ioselectors_kqueue.nim b/lib/pure/ioselects/ioselectors_kqueue.nim index 29a201863..3e86f19aa 100644 --- a/lib/pure/ioselects/ioselectors_kqueue.nim +++ b/lib/pure/ioselects/ioselectors_kqueue.nim @@ -16,6 +16,10 @@ const MAX_KQUEUE_CHANGE_EVENTS = 64 # Maximum number of events that can be returned. MAX_KQUEUE_RESULT_EVENTS = 64 + # SIG_IGN and SIG_DFL declared in posix.nim as variables, but we need them + # to be constants and GC-safe. + SIG_DFL = cast[proc(x: cint) {.noconv,gcsafe.}](0) + SIG_IGN = cast[proc(x: cint) {.noconv,gcsafe.}](1) when defined(macosx) or defined(freebsd): when defined(macosx): diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 9501f6dc7..bd208761b 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -205,6 +205,10 @@ proc newSocket*(fd: SocketHandle, domain: Domain = AF_INET, if buffered: result.currPos = 0 + # Set SO_NOSIGPIPE on OS X. + when defined(macosx): + setSockOptInt(fd, SOL_SOCKET, SO_NOSIGPIPE, 1) + proc newSocket*(domain, sockType, protocol: cint, buffered = true): Socket = ## Creates a new socket. ## @@ -342,8 +346,6 @@ when defineSsl: result = SSLContext(context: newCTX, extraInternalIndex: 0, referencedData: initSet[int]()) result.extraInternalIndex = getExtraDataIndex(result) - # The PSK callback functions assume the internal index is 0. - assert result.extraInternalIndex == 0 let extraInternal = new(SslContextExtraInternal) result.setExtraData(result.extraInternalIndex, extraInternal) @@ -392,6 +394,8 @@ when defineSsl: ## ## Only used in PSK ciphersuites. ctx.getExtraInternal().clientGetPskFunc = fun + assert ctx.extraInternalIndex == 0, + "The pskClientCallback assumes the extraInternalIndex is 0" ctx.context.SSL_CTX_set_psk_client_callback( if fun == nil: nil else: pskClientCallback) |