Skip to content

Commit

Permalink
Removed unused state functions
Browse files Browse the repository at this point in the history
This removes the SetStoppedLocking, and
SetRestartingLocking functions, which
were not used anywhere.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Sep 20, 2016
1 parent fe0d7e0 commit a28c389
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
19 changes: 2 additions & 17 deletions container/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func wait(waitChan <-chan struct{}, timeout time.Duration) error {

// WaitStop waits until state is stopped. If state already stopped it returns
// immediately. If you want wait forever you must supply negative timeout.
// Returns exit code, that was passed to SetStoppedLocking
// Returns exit code, that was passed to SetStopped
func (s *State) WaitStop(timeout time.Duration) (int, error) {
s.Lock()
if !s.Running {
Expand Down Expand Up @@ -243,13 +243,6 @@ func (s *State) SetRunning(pid int, initial bool) {
}
}

// SetStoppedLocking locks the container state and sets it to "stopped".
func (s *State) SetStoppedLocking(exitStatus *ExitStatus) {
s.Lock()
s.SetStopped(exitStatus)
s.Unlock()
}

// SetStopped sets the container state to "stopped" without locking.
func (s *State) SetStopped(exitStatus *ExitStatus) {
s.Running = false
Expand All @@ -262,15 +255,7 @@ func (s *State) SetStopped(exitStatus *ExitStatus) {
s.waitChan = make(chan struct{})
}

// SetRestartingLocking is when docker handles the auto restart of containers when they are
// in the middle of a stop and being restarted again
func (s *State) SetRestartingLocking(exitStatus *ExitStatus) {
s.Lock()
s.SetRestarting(exitStatus)
s.Unlock()
}

// SetRestarting sets the container state to "restarting".
// SetRestarting sets the container state to "restarting" without locking.
// It also sets the container PID to 0.
func (s *State) SetRestarting(exitStatus *ExitStatus) {
// we should consider the container running when it is restarting because of
Expand Down
8 changes: 6 additions & 2 deletions container/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func TestStateRunStop(t *testing.T) {
atomic.StoreInt64(&exit, int64(exitCode))
close(stopped)
}()
s.SetStoppedLocking(&ExitStatus{ExitCode: i})
s.Lock()
s.SetStopped(&ExitStatus{ExitCode: i})
s.Unlock()
if s.IsRunning() {
t.Fatal("State is running")
}
Expand Down Expand Up @@ -70,7 +72,9 @@ func TestStateTimeoutWait(t *testing.T) {
t.Log("Stop callback fired")
}

s.SetStoppedLocking(&ExitStatus{ExitCode: 1})
s.Lock()
s.SetStopped(&ExitStatus{ExitCode: 1})
s.Unlock()

stopped = make(chan struct{})
go func() {
Expand Down

0 comments on commit a28c389

Please sign in to comment.