From a04cca278a368cead0c764ca0e440c323f0ea272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Tue, 6 Mar 2018 13:45:40 +0000 Subject: [PATCH] Add path to UNIXSocket created by UNIXServer --- spec/std/socket_spec.cr | 4 ++-- src/socket/unix_server.cr | 2 +- src/socket/unix_socket.cr | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/std/socket_spec.cr b/spec/std/socket_spec.cr index 357af4a752f6..90aee0963d64 100644 --- a/spec/std/socket_spec.cr +++ b/spec/std/socket_spec.cr @@ -325,10 +325,10 @@ describe UNIXSocket do server.accept do |sock| sock.local_address.family.should eq(Socket::Family::UNIX) - sock.local_address.path.should eq("") + sock.local_address.path.should eq(path) sock.remote_address.family.should eq(Socket::Family::UNIX) - sock.remote_address.path.should eq("") + sock.remote_address.path.should eq(path) client << "ping" sock.gets(4).should eq("ping") diff --git a/src/socket/unix_server.cr b/src/socket/unix_server.cr index ea8f758e4257..e781443e1f9d 100644 --- a/src/socket/unix_server.cr +++ b/src/socket/unix_server.cr @@ -64,7 +64,7 @@ class UNIXServer < UNIXSocket # this method. def accept? : UNIXSocket? if client_fd = accept_impl - sock = UNIXSocket.new(client_fd, type) + sock = UNIXSocket.new(client_fd, type, @path) sock.sync = sync? sock end diff --git a/src/socket/unix_socket.cr b/src/socket/unix_socket.cr index 777941efca6f..9956306a929b 100644 --- a/src/socket/unix_socket.cr +++ b/src/socket/unix_socket.cr @@ -28,7 +28,7 @@ class UNIXSocket < Socket super family, type, Protocol::IP end - protected def initialize(fd : Int32, type : Type) + protected def initialize(fd : Int32, type : Type, @path : String? = nil) super fd, Family::UNIX, type, Protocol::IP end