Skip to content

Commit a28c389

Browse files
committed
Removed unused state functions
This removes the SetStoppedLocking, and SetRestartingLocking functions, which were not used anywhere. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent fe0d7e0 commit a28c389

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

container/state.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func wait(waitChan <-chan struct{}, timeout time.Duration) error {
156156

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

246-
// SetStoppedLocking locks the container state and sets it to "stopped".
247-
func (s *State) SetStoppedLocking(exitStatus *ExitStatus) {
248-
s.Lock()
249-
s.SetStopped(exitStatus)
250-
s.Unlock()
251-
}
252-
253246
// SetStopped sets the container state to "stopped" without locking.
254247
func (s *State) SetStopped(exitStatus *ExitStatus) {
255248
s.Running = false
@@ -262,15 +255,7 @@ func (s *State) SetStopped(exitStatus *ExitStatus) {
262255
s.waitChan = make(chan struct{})
263256
}
264257

265-
// SetRestartingLocking is when docker handles the auto restart of containers when they are
266-
// in the middle of a stop and being restarted again
267-
func (s *State) SetRestartingLocking(exitStatus *ExitStatus) {
268-
s.Lock()
269-
s.SetRestarting(exitStatus)
270-
s.Unlock()
271-
}
272-
273-
// SetRestarting sets the container state to "restarting".
258+
// SetRestarting sets the container state to "restarting" without locking.
274259
// It also sets the container PID to 0.
275260
func (s *State) SetRestarting(exitStatus *ExitStatus) {
276261
// we should consider the container running when it is restarting because of

container/state_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ func TestStateRunStop(t *testing.T) {
3030
atomic.StoreInt64(&exit, int64(exitCode))
3131
close(stopped)
3232
}()
33-
s.SetStoppedLocking(&ExitStatus{ExitCode: i})
33+
s.Lock()
34+
s.SetStopped(&ExitStatus{ExitCode: i})
35+
s.Unlock()
3436
if s.IsRunning() {
3537
t.Fatal("State is running")
3638
}
@@ -70,7 +72,9 @@ func TestStateTimeoutWait(t *testing.T) {
7072
t.Log("Stop callback fired")
7173
}
7274

73-
s.SetStoppedLocking(&ExitStatus{ExitCode: 1})
75+
s.Lock()
76+
s.SetStopped(&ExitStatus{ExitCode: 1})
77+
s.Unlock()
7478

7579
stopped = make(chan struct{})
7680
go func() {

0 commit comments

Comments
 (0)