Skip to content

Commit

Permalink
Automatically retry on would block
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Jan 25, 2022
1 parent 0e138bc commit ff7785e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/io/io_linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,14 @@ pub const Completion = struct {
},
.connect => {
const result = if (completion.result < 0) switch (-completion.result) {
os.EINTR => {
os.EAGAIN, os.EINPROGRESS, os.EINTR => {
completion.io.enqueue(completion);
return;
},
os.EACCES => error.AccessDenied,
os.EADDRINUSE => error.AddressInUse,
os.EADDRNOTAVAIL => error.AddressNotAvailable,
os.EAFNOSUPPORT => error.AddressFamilyNotSupported,
os.EAGAIN, os.EINPROGRESS => error.WouldBlock,
os.EALREADY => error.OpenAlreadyInProgress,
os.EBADF => error.FileDescriptorInvalid,
os.ECONNREFUSED => error.ConnectionRefused,
Expand Down Expand Up @@ -840,11 +839,10 @@ pub const Completion = struct {
},
.read => {
const result = if (completion.result < 0) switch (-completion.result) {
os.EINTR => {
os.EAGAIN, os.EINTR => {
completion.io.enqueue(completion);
return;
},
os.EAGAIN => error.WouldBlock,
os.EBADF => error.NotOpenForReading,
os.ECONNRESET => error.ConnectionResetByPeer,
os.EINVAL => error.Alignment,
Expand All @@ -861,11 +859,10 @@ pub const Completion = struct {
},
.readev, .recv => {
const result = if (completion.result < 0) switch (-completion.result) {
os.EINTR => {
os.EAGAIN, os.EINTR => {
completion.io.enqueue(completion);
return;
},
os.EAGAIN => error.WouldBlock,
os.EBADF => error.FileDescriptorInvalid,
os.ECONNREFUSED => error.ConnectionRefused,
os.ENOMEM => error.SystemResources,
Expand All @@ -878,12 +875,11 @@ pub const Completion = struct {
},
.writev, .send => {
const result = if (completion.result < 0) switch (-completion.result) {
os.EINTR => {
os.EAGAIN, os.EINTR => {
completion.io.enqueue(completion);
return;
},
os.EACCES => error.AccessDenied,
os.EAGAIN => error.WouldBlock,
os.EALREADY => error.FastOpenAlreadyInProgress,
os.EAFNOSUPPORT => error.AddressFamilyNotSupported,
os.EBADF => error.FileDescriptorInvalid,
Expand Down

0 comments on commit ff7785e

Please sign in to comment.