Skip to content

Commit

Permalink
Merge pull request #48 from nim-lang/Clonkk-patch-1
Browse files Browse the repository at this point in the history
Update connections.nim
  • Loading branch information
Araq authored Nov 4, 2024
2 parents 6eb2f6e + df2010a commit 4cc1ca3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@ on:
- master

jobs:
default:
runs-on: ubuntu-latest
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
nim:
- '2.0.x'
- 'stable'
- devel
os:
- ubuntu-latest

name: '${{ matrix.nim }} (${{ matrix.os }})'
steps:
- uses: actions/checkout@v4
- uses: iffy/install-nim@v5
- name: Setup nim
uses: jiro4989/setup-nim-action@v2
with:
use-nightlies: true
nim-version: ${{ matrix.nim }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- run: nimble install -y
- run: nimble test
- run: nimble test --gc:arc
Expand Down
2 changes: 1 addition & 1 deletion zmq.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "1.5.2"
version = "1.5.3"
author = "Andreas Rumpf"
description = "ZeroMQ wrapper"
license = "MIT"
Expand Down
8 changes: 4 additions & 4 deletions zmq/connections.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ proc terminate*(ctx: ZContext) =
get/set socket options
Declare socket options first because it's used in =destroy hooks
]#

# Some option take cint, int64 or uint64
proc setsockopt_impl[T: SomeOrdinal](s: ZSocket, option: ZSockOptions, optval: T) =
var val: T = optval
Expand All @@ -106,17 +107,16 @@ proc setsockopt_impl(s: ZSocket, option: ZSockOptions, optval: string) =
# some sockopt returns integer values
proc getsockopt_impl[T: SomeOrdinal](s: ZSocket, option: ZSockOptions, optval: var T) =
var optval_len: int = sizeof(optval)

if bindings.getsockopt(s, option, addr(optval), addr(optval_len)) != 0:
zmqError()

# Some sockopt returns a string
proc getsockopt_impl(s: ZSocket, option: ZSockOptions, optval: var string) =
var optval_len: int = optval.len

if bindings.getsockopt(s, option, cstring(optval), addr(optval_len)) != 0:
zmqError()


#[
Public set/get sockopt function on ZSocket / ZConnection
]#
Expand All @@ -125,7 +125,7 @@ proc setsockopt*[T: SomeOrdinal|string](s: ZSocket, option: ZSockOptions, optval
##
## Careful, the ``sizeof`` of ``optval`` depends on the ``ZSockOptions`` passed.
## Check http://api.zeromq.org/4-2:zmq-setsockopt
setsockopt_impl[T](s, option, optval)
setsockopt_impl(s, option, optval)

proc setsockopt[T: SomeOrdinal|string](c: ZConnectionImpl, option: ZSockOptions, optval: T) =
## Internal
Expand Down Expand Up @@ -323,7 +323,7 @@ proc close(c: var ZConnectionImpl, linger: int = 500) =
c.context.terminate()

proc close*(c: ZConnection, linger: int = 500) =
c[].close()
close(c[], linger)

# Send / Receive
# Send with ZSocket type
Expand Down

0 comments on commit 4cc1ca3

Please sign in to comment.