59 lines
1.8 KiB
Diff
59 lines
1.8 KiB
Diff
From 256b247e9fa9844c8e0760679411427d43b661c9 Mon Sep 17 00:00:00 2001
|
|
From: wangfengtu <wangfengtu@huawei.com>
|
|
Date: Wed, 5 Sep 2018 15:16:28 +0800
|
|
Subject: [PATCH 63/94] docker: close openchan immediately to avoid
|
|
error
|
|
|
|
reason: close openchan immediately to avoid error
|
|
|
|
Change-Id: I20664570518ea424088a4eb6a5aac3d38ac08449
|
|
Signed-off-by: wangfengtu <wangfengtu@huawei.com>
|
|
---
|
|
libcontainer/container_linux.go | 13 +++++++++----
|
|
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go
|
|
index ba5dcd6..61ffb76 100644
|
|
--- a/libcontainer/container_linux.go
|
|
+++ b/libcontainer/container_linux.go
|
|
@@ -245,8 +245,7 @@ func (c *linuxContainer) exec() error {
|
|
select {
|
|
case <-awaitProcessExit(c.initProcess.pid(), fifoOpen):
|
|
return errors.New("container process is already dead")
|
|
- case result := <-awaitFifoOpen(path):
|
|
- close(fifoOpen)
|
|
+ case result := <-awaitFifoOpen(path, fifoOpen):
|
|
if result.err != nil {
|
|
return result.err
|
|
}
|
|
@@ -283,7 +282,12 @@ func awaitProcessExit(pid int, exit <-chan struct{}) <-chan struct{} {
|
|
case <-time.After(time.Millisecond * 100):
|
|
stat, err := system.GetProcessState(pid)
|
|
if err != nil || stat == system.Zombie {
|
|
- close(isDead)
|
|
+ select {
|
|
+ case <-exit:
|
|
+ return
|
|
+ default:
|
|
+ close(isDead)
|
|
+ }
|
|
return
|
|
}
|
|
}
|
|
@@ -292,10 +296,11 @@ func awaitProcessExit(pid int, exit <-chan struct{}) <-chan struct{} {
|
|
return isDead
|
|
}
|
|
|
|
-func awaitFifoOpen(path string) <-chan openResult {
|
|
+func awaitFifoOpen(path string, fifoOpen chan struct{}) <-chan openResult {
|
|
fifoOpened := make(chan openResult)
|
|
go func() {
|
|
f, err := os.OpenFile(path, os.O_RDONLY, 0)
|
|
+ close(fifoOpen)
|
|
if err != nil {
|
|
fifoOpened <- openResult{err: newSystemErrorWithCause(err, "open exec fifo for reading")}
|
|
return
|
|
--
|
|
2.7.4.3
|
|
|