summaryrefslogtreecommitdiff
path: root/internal/eventloop.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-24 21:37:54 +0200
committerPaul Buetow <paul@buetow.org>2025-03-24 21:37:54 +0200
commit26be49ea3cc2516ab7d26b629e7edc93a296596d (patch)
tree49f6d8730a937375a755291037b3d388abb1f0cf /internal/eventloop.go
parent6834a4c4094d133e771491b134e8da73a9f00a07 (diff)
parenta78769805d408308a1d85f9b2fb45a1af3450f13 (diff)
add fork testMerge branch 'main' of codeberg.org:snonux/ior
Diffstat (limited to 'internal/eventloop.go')
-rw-r--r--internal/eventloop.go34
1 files changed, 19 insertions, 15 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index ae3f887..f7bfa9a 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -51,7 +51,7 @@ func newEventLoop(flags flags.Flags) *eventLoop {
}
func (e *eventLoop) stats() string {
- fmt.Println("Waiting for staps to be ready")
+ fmt.Println("Waiting for stats to be ready")
<-e.done
duration := time.Since(e.startTime)
@@ -111,13 +111,11 @@ func (e *eventLoop) events(ctx context.Context, rawCh <-chan []byte) <-chan *eve
continue
}
e.processRawEvent(raw, ch)
+ case <-ctx.Done():
+ fmt.Println("Stopping event loop")
+ return
default:
- select {
- case <-ctx.Done():
- return
- default:
- time.Sleep(time.Millisecond * 10)
- }
+ time.Sleep(time.Millisecond * 10)
}
}
}()
@@ -264,21 +262,27 @@ func (e *eventLoop) syscallExit(exitEv event.Event, ch chan<- *event.Pair) {
break
}
+ fdFile, ok := ev.File.(file.FdFile)
+ if !ok {
+ panic("expected a file.FdFile")
+ }
+
+ // See fcntl(2) for implementation details
switch v.Cmd {
case syscall.F_SETFL:
- fdFile, ok := ev.File.(file.FdFile)
- if !ok {
- panic("expected a file.FdFile")
- }
- // fcntl(2)
+ fmt.Println("DEBUG", fdFile)
canChange := syscall.O_APPEND | syscall.O_ASYNC | syscall.O_DIRECT | syscall.O_NOATIME | syscall.O_NONBLOCK
- fdFile.Flags |= (int32(v.Arg) & int32(canChange))
+ *fdFile.Flags |= (int32(v.Arg) & int32(canChange))
ev.File = fdFile
e.files[fd] = fdFile
case syscall.F_DUPFD:
- fmt.Println("TODO: F_DUPFD with fcntl not yet implememented")
+ newFd := int32(retEvent.Ret)
+ e.files[newFd] = fdFile.Dup(newFd)
case syscall.F_DUPFD_CLOEXEC:
- fmt.Println("TODO: F_DUPFD_CLOEXEC with fcntl not yet implememented")
+ newFd := int32(retEvent.Ret)
+ duppedFd := fdFile.Dup(newFd)
+ *duppedFd.Flags |= syscall.O_CLOEXEC
+ e.files[newFd] = duppedFd
}
default: