Skip to content

Commit 5f63d47

Browse files
committed
Dispatch by platform at load
`RUBY_PLATFORM` should be invariant within the same process.
1 parent ae7415c commit 5f63d47

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/socket/lib/socket.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,13 +1569,16 @@ def self.unix_server_socket(path)
15691569
end
15701570
end
15711571

1572-
class << self
1573-
private
1574-
1575-
def unix_socket_abstract_name?(path)
1576-
/linux/ =~ RUBY_PLATFORM && /\A(\0|\z)/ =~ path
1572+
if RUBY_PLATFORM.include?("linux")
1573+
def self.unix_socket_abstract_name?(path)
1574+
path.empty? or path.start_with?("\0")
1575+
end
1576+
else
1577+
def self.unix_socket_abstract_name?(path)
1578+
false
15771579
end
15781580
end
1581+
private_class_method :unix_socket_abstract_name?
15791582

15801583
# creates a UNIX socket server on _path_.
15811584
# It calls the block for each socket accepted.

0 commit comments

Comments
 (0)