Skip to content

Commit

Permalink
Solve issue petergoldstein#523 - UNIX sockets on windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
dfens authored and Pawel Mikolajewski committed Mar 17, 2015
1 parent 354e24e commit 26f96e9
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/dalli/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,25 @@ def self.open(host, port, server, options = {})
end
end

class Dalli::Server::KSocket::UNIX < UNIXSocket
include Dalli::Server::KSocket

def self.open(path, server, options = {})
Timeout.timeout(options[:socket_timeout]) do
sock = new(path)
sock.options = {:path => path}.merge(options)
sock.server = server
sock
if RUBY_PLATFORM =~ /mingw|mswin/
class Dalli::Server::KSocket::UNIX
def initialize(*args)
raise Dalli::DalliError, "Unix sockets are not supported on Windows platform."
end
end
else
class Dalli::Server::KSocket::UNIX < UNIXSocket
include Dalli::Server::KSocket

def self.open(path, server, options = {})
Timeout.timeout(options[:socket_timeout]) do
sock = new(path)
sock.options = {:path => path}.merge(options)
sock.server = server
sock
end
end
end
end

end
end

0 comments on commit 26f96e9

Please sign in to comment.