Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ platform :mri, :truffleruby do
gem "xorcist", require: false
end

if RUBY_VERSION >= "3.0.0"
gem "rubocop"
gem "rubocop-performance"
platform :mri do
if RUBY_VERSION >= "3.0.0"
gem "celluloid-io", "~> 0.17" if RUBY_VERSION >= "2.3.0"
gem "rbs"
gem "rubocop"
gem "rubocop-performance"
end
end

gem "rbs" if RUBY_VERSION >= "3.0"

if RUBY_VERSION < "2.3"
gem "simplecov", "< 0.11.0"
elsif RUBY_VERSION < "2.4"
Expand All @@ -31,4 +33,3 @@ else
gem "simplecov"
end

gem "celluloid-io", "~> 0.17" if RUBY_VERSION >= "2.3.0"
2 changes: 1 addition & 1 deletion docker-compose-jruby.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
netsnmp:
image: jruby:9.2
image: jruby:9.4
environment:
- JRUBY_OPTS=--debug
entrypoint:
Expand Down
31 changes: 23 additions & 8 deletions lib/netsnmp/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,31 @@ def send(payload)

SOCK_FLAGS = Socket.const_defined?(:MSG_DONTWAIT) ? Socket::MSG_DONTWAIT : 0

def write(payload)
perform_io do
@socket.sendmsg(payload, SOCK_FLAGS, @destaddr)
if RUBY_ENGINE == "jruby"
def write(payload)
perform_io do
@socket.send(payload, SOCK_FLAGS, @destaddr)
end
end
end

def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recvmsg_nonblock(bytesize, SOCK_FLAGS)
datagram
def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recv_nonblock(bytesize, SOCK_FLAGS)
datagram
end
end
else
def write(payload)
perform_io do
@socket.sendmsg(payload, SOCK_FLAGS, @destaddr)
end
end

def recv(bytesize = MAXPDUSIZE)
perform_io do
datagram, = @socket.recvmsg_nonblock(bytesize, SOCK_FLAGS)
datagram
end
end
end

Expand Down