Tidy receive_stream
This commit is contained in:
@@ -153,10 +153,11 @@ module Netlink
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Loop infinitely receiving messages of given type(s), ignoring pid and seq.
|
# Loop infinitely receiving messages of given type(s), ignoring pid and seq.
|
||||||
def receive_stream(*expected_type)
|
# Raises an exception on NLMSG_ERROR.
|
||||||
|
def receive_stream(*expected_types)
|
||||||
loop do
|
loop do
|
||||||
receive_response(nil) do |type, flags, seq, pid, msg|
|
receive_response(nil) do |type, flags, seq, pid, msg|
|
||||||
if expected_type.include?(type)
|
if expected_types.include?(type)
|
||||||
yield msg
|
yield msg
|
||||||
elsif type == NLMSG_ERROR
|
elsif type == NLMSG_ERROR
|
||||||
raise ERRNO_MAP[-msg.error] || "Netlink Error: #{msg.inspect}"
|
raise ERRNO_MAP[-msg.error] || "Netlink Error: #{msg.inspect}"
|
||||||
|
Reference in New Issue
Block a user