1
0
forked from rosa/hakurei

cmd/mbf: optionally wait for cancel

Synchronisation is not needed here during interactive use.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-19 18:24:11 +09:00
parent f8902e3679
commit 753432cf09
3 changed files with 11 additions and 7 deletions

View File

@@ -305,6 +305,7 @@ func cancelRemote(
ctx context.Context,
addr *net.UnixAddr,
a pkg.Artifact,
wait bool,
) error {
done, conn, err := dial(ctx, addr)
if err != nil {
@@ -323,8 +324,10 @@ func cancelRemote(
} else if n != len(id) {
return errors.Join(io.ErrShortWrite, conn.Close())
}
if _, err = conn.Read(make([]byte, 1)); err == io.EOF {
err = nil
if wait {
if _, err = conn.Read(make([]byte, 1)); err == io.EOF {
err = nil
}
}
return errors.Join(err, conn.Close())
}
@@ -333,6 +336,7 @@ func cancelRemote(
func abortRemote(
ctx context.Context,
addr *net.UnixAddr,
wait bool,
) error {
done, conn, err := dial(ctx, addr)
if err != nil {
@@ -341,7 +345,7 @@ func abortRemote(
defer close(done)
err = writeSpecialHeader(conn, specialAbort)
if err == nil {
if wait && err == nil {
if _, err = conn.Read(make([]byte, 1)); err == io.EOF {
err = nil
}