Fix repeated sending signal

Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
This commit is contained in:
Shiming Zhang
2021-02-08 17:35:30 +08:00
committed by wzshiming
parent ddcc431c11
commit dc6f5ef3b9
2 changed files with 23 additions and 5 deletions

View File

@@ -42,6 +42,9 @@ type Container struct {
IO *cio.ContainerIO
// StopCh is used to propagate the stop information of the container.
*store.StopCh
// IsStopSignaledWithTimeout the default is 0, and it is set to 1 after sending
// the signal once to avoid repeated sending of the signal.
IsStopSignaledWithTimeout *uint32
}
// Opts sets specific information to newly created Container.
@@ -81,8 +84,9 @@ func WithStatus(status Status, root string) Opts {
// NewContainer creates an internally used container type.
func NewContainer(metadata Metadata, opts ...Opts) (Container, error) {
c := Container{
Metadata: metadata,
StopCh: store.NewStopCh(),
Metadata: metadata,
StopCh: store.NewStopCh(),
IsStopSignaledWithTimeout: new(uint32),
}
for _, o := range opts {
if err := o(&c); err != nil {