change flag from RDONLY to RDWR and close the fifo correct
Signed-off-by: Zhiyu Li <payall4u@qq.com>
This commit is contained in:
parent
20346607b9
commit
957fa3379d
@ -115,6 +115,7 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
|
||||
onCloseWithShimLog := func() {
|
||||
onClose()
|
||||
cancelShimLog()
|
||||
f.Close()
|
||||
}
|
||||
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
|
||||
return &shim{
|
||||
|
@ -76,7 +76,13 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
|
||||
conn.Close()
|
||||
}
|
||||
}()
|
||||
f, err := openShimLog(ctx, bundle, client.AnonReconnectDialer)
|
||||
shimCtx, cancelShimLog := context.WithCancel(ctx)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
cancelShimLog()
|
||||
}
|
||||
}()
|
||||
f, err := openShimLog(shimCtx, bundle, client.AnonReconnectDialer)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "open shim log pipe")
|
||||
}
|
||||
@ -99,8 +105,12 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
|
||||
onCloseWithShimLog := func() {
|
||||
onClose()
|
||||
cancelShimLog()
|
||||
f.Close()
|
||||
}
|
||||
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
|
||||
defer func() {
|
||||
if err != nil {
|
||||
client.Close()
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func openShimLog(ctx context.Context, bundle *Bundle, _ func(string, time.Duration) (net.Conn, error)) (io.ReadCloser, error) {
|
||||
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDONLY|unix.O_CREAT|unix.O_NONBLOCK, 0700)
|
||||
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDWR|unix.O_CREAT|unix.O_NONBLOCK, 0700)
|
||||
}
|
||||
|
||||
func checkCopyShimLogError(ctx context.Context, err error) error {
|
||||
|
Loading…
Reference in New Issue
Block a user