Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
Fix close a nil chan err
Browse files Browse the repository at this point in the history
If docker exec to a container, and then kill the runtime's shim process
it will close a nil chan in Supervisor' execExit interface.

Supervisor.exit
            |---> s.delete
            |         |
            |         V
            |     execMap := s.getDeleteExecSyncMap(t.ID) make getExecSyncChannel return nil
            |
            |--->s.execExit
            |         |
            |         V
            |     synCh := s.getExecSyncChannel(t.ID, t.PID)
            |         |
            |         V
            |     close(synCh) close a nil chan make container panic

Signed-off-by: yangshukui <yangshukui@huawei.com>
(cherry picked from commit de0e943)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
  • Loading branch information
yangshukui authored and mlaventure committed Jun 5, 2017
1 parent b66ba7a commit 6e5b935
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion supervisor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ func (s *Supervisor) delete(t *DeleteTask) error {
t.Process.Wait()
}
if !t.NoEvent {
execMap := s.getDeleteExecSyncMap(t.ID)
execMap := s.getExecSyncMap(t.ID)
go func() {
// Wait for all exec processe events to be sent (we seem
// to sometimes receive them after the init event)
for _, ch := range execMap {
<-ch
}
s.deleteExecSyncMap(t.ID)
s.notifySubscribers(Event{
Type: StateExit,
Timestamp: time.Now(),
Expand Down
12 changes: 8 additions & 4 deletions supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,14 @@ func (s *Supervisor) getExecSyncChannel(containerID, pid string) chan struct{} {
return ch
}

func (s *Supervisor) getDeleteExecSyncMap(containerID string) map[string]chan struct{} {
func (s *Supervisor) getExecSyncMap(containerID string) map[string]chan struct{} {
s.containerExecSyncLock.Lock()
chs := s.containerExecSync[containerID]
defer s.containerExecSyncLock.Unlock()
return s.containerExecSync[containerID]
}

func (s *Supervisor) deleteExecSyncMap(containerID string) {
s.containerExecSyncLock.Lock()
defer s.containerExecSyncLock.Unlock()
delete(s.containerExecSync, containerID)
s.containerExecSyncLock.Unlock()
return chs
}

0 comments on commit 6e5b935

Please sign in to comment.