From a325343ea5e50d28ee02108ee9ec81747f53b553 Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Thu, 14 Oct 2021 10:45:54 -0700 Subject: [PATCH] Don't load UNIXSocket on Windows systems --- lib/dalli/socket.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/dalli/socket.rb b/lib/dalli/socket.rb index 837efbe6..f632e82d 100644 --- a/lib/dalli/socket.rb +++ b/lib/dalli/socket.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'openssl' +require 'rbconfig' module Dalli module Socket @@ -77,8 +78,16 @@ def self.open(host, port, server, options = {}) end end end + end - class UNIX < UNIXSocket + if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ + class Dalli::Socket::UNIX + def initialize(*args) + raise Dalli::DalliError, 'Unix sockets are not supported on Windows platform.' + end + end + else + class Dalli::Socket::UNIX < UNIXSocket include Dalli::Socket::InstanceMethods attr_accessor :options, :server