Skip to content

Commit 8db34f4

Browse files
committed
Wrap LibC.getaddrinfo in syscall(&) on UNIX and Windows 7
1 parent 455df09 commit 8db34f4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/crystal/system/unix/addrinfo.cr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ module Crystal::System::Addrinfo
4949
end
5050
{% end %}
5151

52-
ret = LibC.getaddrinfo(domain, service.to_s, pointerof(hints), out ptr)
52+
ptr = Pointer(LibC::Addrinfo).null
53+
ret = ::Fiber.syscall do
54+
LibC.getaddrinfo(domain, service.to_s, pointerof(hints), pointerof(ptr))
55+
end
5356
unless ret.zero?
5457
if ret == LibC::EAI_SYSTEM
5558
raise ::Socket::Addrinfo::Error.from_os_error nil, Errno.value, domain: domain

src/crystal/system/win32/addrinfo_win7.cr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ module Crystal::System::Addrinfo
4343
end
4444
end
4545

46-
ret = LibC.getaddrinfo(domain, service.to_s, pointerof(hints), out ptr)
46+
ptr = Pointer(LibC::Addrinfo).null
47+
ret = ::Fiber.syscall do
48+
LibC.getaddrinfo(domain, service.to_s, pointerof(hints), pointerof(ptr))
49+
end
4750
unless ret.zero?
4851
error = WinError.new(ret.to_u32!)
4952
raise ::Socket::Addrinfo::Error.from_os_error(nil, error, domain: domain, type: type, protocol: protocol, service: service)

0 commit comments

Comments
 (0)