summaryrefslogtreecommitdiffhomepage
path: root/ipc/namedpipe/namedpipe.go
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/namedpipe/namedpipe.go')
-rw-r--r--ipc/namedpipe/namedpipe.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/ipc/namedpipe/namedpipe.go b/ipc/namedpipe/namedpipe.go
index 6db5ea3..92cc1ee 100644
--- a/ipc/namedpipe/namedpipe.go
+++ b/ipc/namedpipe/namedpipe.go
@@ -29,7 +29,7 @@ type pipe struct {
type messageBytePipe struct {
pipe
- writeClosed int32
+ writeClosed atomic.Bool
readEOF bool
}
@@ -51,17 +51,17 @@ func (f *pipe) SetDeadline(t time.Time) error {
// CloseWrite closes the write side of a message pipe in byte mode.
func (f *messageBytePipe) CloseWrite() error {
- if !atomic.CompareAndSwapInt32(&f.writeClosed, 0, 1) {
+ if !f.writeClosed.CompareAndSwap(false, true) {
return io.ErrClosedPipe
}
err := f.file.Flush()
if err != nil {
- atomic.StoreInt32(&f.writeClosed, 0)
+ f.writeClosed.Store(false)
return err
}
_, err = f.file.Write(nil)
if err != nil {
- atomic.StoreInt32(&f.writeClosed, 0)
+ f.writeClosed.Store(false)
return err
}
return nil
@@ -70,7 +70,7 @@ func (f *messageBytePipe) CloseWrite() error {
// Write writes bytes to a message pipe in byte mode. Zero-byte writes are ignored, since
// they are used to implement CloseWrite.
func (f *messageBytePipe) Write(b []byte) (int, error) {
- if atomic.LoadInt32(&f.writeClosed) != 0 {
+ if f.writeClosed.Load() {
return 0, io.ErrClosedPipe
}
if len(b) == 0 {