Skip to content

Commit

Permalink
Improve comments in code
Browse files Browse the repository at this point in the history
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
  • Loading branch information
evacchi committed Aug 2, 2023
1 parent 943afcf commit dc50c2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 7 additions & 4 deletions imports/wasi_snapshot_preview1/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
// - sys.ENOTSUP: a parameters is valid, but not yet supported.
// - sys.EFAULT: there is not enough memory to read the subscriptions or
// write results.
// - sys.EINTR: an OS interrupt has occurred while invoking the syscall.
//
// # Notes
//
Expand Down Expand Up @@ -95,6 +96,8 @@ func pollOneoffFn(_ context.Context, mod api.Module, params []uint64) sys.Errno
// The timeout is initialized at max Duration, the loop will find the minimum.
var timeout time.Duration = 1<<63 - 1
// Count of all the subscriptions that have been already written back to outBuf.
// nevents*32 returns at all times the offset where the next event should be written:
// this way we ensure that there are no gaps between records.
nevents := uint32(0)

// Layout is subscription_u: Union
Expand Down Expand Up @@ -136,14 +139,14 @@ func pollOneoffFn(_ context.Context, mod api.Module, params []uint64) sys.Errno
evt.errno = wasip1.ErrnoBadf
writeEvent(outBuf[outOffset:], evt)
nevents++
} else if !file.File.IsNonblock() {
} else if file.File.IsNonblock() {
writeEvent(outBuf[outOffset:], evt)
nevents++
} else {
// If the fd is blocking, do not ack yet,
// append to a slice for delayed evaluation.
fe := &filePollEvent{f: file, e: evt}
blockingSubs = append(blockingSubs, fe)
} else {
writeEvent(outBuf[outOffset:], evt)
nevents++
}
case wasip1.EventTypeFdWrite:
fd := int32(le.Uint32(argBuf))
Expand Down
4 changes: 0 additions & 4 deletions imports/wasi_snapshot_preview1/poll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ func Test_pollOneoff_Mixed(t *testing.T) {

tests := []struct {
name string
skip bool
in, out, nsubscriptions, resultNevents uint32
connected, nonblocking bool
mem []byte // at offset in
Expand Down Expand Up @@ -620,9 +619,6 @@ func Test_pollOneoff_Mixed(t *testing.T) {
tc := tt

t.Run(tc.name, func(t *testing.T) {
if tc.skip {
t.Skip()
}
ctx := sock.WithConfig(testCtx,
sock.NewConfig().WithTCPListener("127.0.0.1", 0))

Expand Down

0 comments on commit dc50c2b

Please sign in to comment.