Skip to content

Commit edffc83

Browse files
committed
change flag from RDONLY to RDWR and close the fifo correct
Signed-off-by: Zhiyu Li <payall4u@qq.com> (cherry picked from commit 957fa33)
1 parent c36f12a commit edffc83

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

runtime/v2/binary.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
115115
onCloseWithShimLog := func() {
116116
onClose()
117117
cancelShimLog()
118+
f.Close()
118119
}
119120
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
120121
return &shim{

runtime/v2/shim.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
7676
conn.Close()
7777
}
7878
}()
79-
f, err := openShimLog(ctx, bundle, client.AnonReconnectDialer)
79+
shimCtx, cancelShimLog := context.WithCancel(ctx)
80+
defer func() {
81+
if err != nil {
82+
cancelShimLog()
83+
}
84+
}()
85+
f, err := openShimLog(shimCtx, bundle, client.AnonReconnectDialer)
8086
if err != nil {
8187
return nil, errors.Wrap(err, "open shim log pipe")
8288
}
@@ -99,8 +105,12 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
99105
}
100106
}
101107
}()
102-
103-
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
108+
onCloseWithShimLog := func() {
109+
onClose()
110+
cancelShimLog()
111+
f.Close()
112+
}
113+
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
104114
defer func() {
105115
if err != nil {
106116
client.Close()

runtime/v2/shim_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
func openShimLog(ctx context.Context, bundle *Bundle, _ func(string, time.Duration) (net.Conn, error)) (io.ReadCloser, error) {
33-
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDONLY|unix.O_CREAT|unix.O_NONBLOCK, 0700)
33+
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDWR|unix.O_CREAT|unix.O_NONBLOCK, 0700)
3434
}
3535

3636
func checkCopyShimLogError(ctx context.Context, err error) error {

0 commit comments

Comments
 (0)