Skip to content

Commit

Permalink
(FACT-3446) Call close(2) with Solaris FFI
Browse files Browse the repository at this point in the history
Previously, when Facter ran on Solaris it would use shutdown(2) to
attempt to close open sockets. However, this would leak file descriptors
and occasionally cause an issue where the system would hit its maximum
open files.

This commit updates Facter to instead use close(2) on Solaris to ensure
that file descriptors are not leaked.
  • Loading branch information
mhashizume committed Oct 26, 2023
1 parent cca2160 commit 612c0e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/facter/resolvers/solaris/ffi/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ module Ioctl

attach_function :ioctl_base, :ioctl, %i[int int pointer], :int
attach_function :open_socket, :socket, %i[int int int], :int
attach_function :close_socket, :shutdown, %i[int int], :int
attach_function :close_socket, :close, %i[int], :int
attach_function :inet_ntop, %i[int pointer pointer uint], :string

def self.ioctl(call_const, pointer, address_family = AF_INET)
fd = Ioctl.open_socket(address_family, SOCK_DGRAM, 0)
begin
ioctl_base(fd, call_const, pointer)
ensure
Ioctl.close_socket(fd, 2)
Ioctl.close_socket(fd)
end
end
end
Expand Down

0 comments on commit 612c0e7

Please sign in to comment.