Skip to content

Commit

Permalink
fix: add context support to pipe checker on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: thediveo <thediveo@gmx.eu>
  • Loading branch information
thediveo committed Dec 20, 2023
1 parent 27241eb commit 5467924
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pipe/checker_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package pipe

import (
"context"
"os"
"syscall"
"time"
Expand All @@ -23,12 +24,15 @@ import (
// unsynchronized concurrent writes are a really bad idea, but in this case
// we're not really writing anything, but just poking things to see if they're
// dead already.
func WaitTillBreak(fifo *os.File) {
func WaitTillBreak(ctx context.Context, fifo *os.File) {
log.Debug("constantly monitoring packet capture fifo status...")
nothing := []byte{}
ticker := time.NewTicker(1 * time.Second)
ticker := time.NewTicker(100 * time.Millisecond)
for {
select {
case <-ctx.Done():
log.Debug("context done while monitoring packet capture fifo")
return
case <-ticker.C:
// Avoid the usual higher level writes, because of their
// optimizations. While at this time the Windows writer
Expand Down

0 comments on commit 5467924

Please sign in to comment.