authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2021-06-22 08:05:18-06:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-23 12:54:20+03:00
log0134cb0214131d1a7edb18a48f54f9d25277cf84
tree8986cc85906e96106a00dcd6d401d7963e1c7b0f
parent29945fb8b3b954e846e3f062600a37b7c1ab47d6

nice error for unsupported async sockets on Windows


2 files changed, 16 insertions(+), 2 deletions(-)

lib/std/event/loop.zig+2-2
...@@ -894,7 +894,7 @@ pub const Loop = struct {...@@ -894,7 +894,7 @@ pub const Loop = struct {
894 self: *Loop,894 self: *Loop,
895 /// This argument is a socket that has been created with `socket`, bound to a local address895 /// This argument is a socket that has been created with `socket`, bound to a local address
896 /// with `bind`, and is listening for connections after a `listen`.896 /// with `bind`, and is listening for connections after a `listen`.
897 sockfd: os.fd_t,897 sockfd: os.socket_t,
898 /// This argument is a pointer to a sockaddr structure. This structure is filled in with the898 /// This argument is a pointer to a sockaddr structure. This structure is filled in with the
899 /// address of the peer socket, as known to the communications layer. The exact format of the899 /// address of the peer socket, as known to the communications layer. The exact format of the
900 /// address returned addr is determined by the socket's address family (see `socket` and the900 /// address returned addr is determined by the socket's address family (see `socket` and the
...@@ -911,7 +911,7 @@ pub const Loop = struct {...@@ -911,7 +911,7 @@ pub const Loop = struct {
911 /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the911 /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the
912 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.912 /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful.
913 flags: u32,913 flags: u32,
914 ) os.AcceptError!os.fd_t {914 ) os.AcceptError!os.socket_t {
915 while (true) {915 while (true) {
916 return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) {916 return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) {
917 error.WouldBlock => {917 error.WouldBlock => {
test/compile_errors.zig+14
...@@ -8439,4 +8439,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -8439,4 +8439,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
8439 , &[_][]const u8{8439 , &[_][]const u8{
8440 "tmp.zig:2:30: error: `.*` cannot be followed by `*`. Are you missing a space?",8440 "tmp.zig:2:30: error: `.*` cannot be followed by `*`. Are you missing a space?",
8441 });8441 });
8442
8443 cases.add("Issue #9165: windows tcp server compilation error",
8444 \\const std = @import("std");
8445 \\pub const io_mode = .evented;
8446 \\pub fn main() !void {
8447 \\ if (std.builtin.os.tag == .windows) {
8448 \\ _ = try (std.net.StreamServer.init(.{})).accept();
8449 \\ } else {
8450 \\ @compileError("Unsupported OS");
8451 \\ }
8452 \\}
8453 , &[_][]const u8{
8454 "error: Unsupported OS",
8455 });
8442}8456}