Merge pull request #2748 from crosbymichael/reaper-buffer
Increase reaper buffer size and non-blocking send
This commit is contained in:
commit
8afcade1a6
@ -26,12 +26,13 @@ import (
|
|||||||
"github.com/containerd/containerd/sys"
|
"github.com/containerd/containerd/sys"
|
||||||
runc "github.com/containerd/go-runc"
|
runc "github.com/containerd/go-runc"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNoSuchProcess is returned when the process no longer exists
|
// ErrNoSuchProcess is returned when the process no longer exists
|
||||||
var ErrNoSuchProcess = errors.New("no such process")
|
var ErrNoSuchProcess = errors.New("no such process")
|
||||||
|
|
||||||
const bufferSize = 32
|
const bufferSize = 2048
|
||||||
|
|
||||||
// Reap should be called when the process receives an SIGCHLD. Reap will reap
|
// Reap should be called when the process receives an SIGCHLD. Reap will reap
|
||||||
// all exited processes and close their wait channels
|
// all exited processes and close their wait channels
|
||||||
@ -41,13 +42,20 @@ func Reap() error {
|
|||||||
Default.Lock()
|
Default.Lock()
|
||||||
for c := range Default.subscribers {
|
for c := range Default.subscribers {
|
||||||
for _, e := range exits {
|
for _, e := range exits {
|
||||||
c <- runc.Exit{
|
select {
|
||||||
|
case c <- runc.Exit{
|
||||||
Timestamp: now,
|
Timestamp: now,
|
||||||
Pid: e.Pid,
|
Pid: e.Pid,
|
||||||
Status: e.Status,
|
Status: e.Status,
|
||||||
|
}:
|
||||||
|
default:
|
||||||
|
logrus.WithFields(logrus.Fields{
|
||||||
|
"subscriber": c,
|
||||||
|
"pid": e.Pid,
|
||||||
|
"status": e.Status,
|
||||||
|
}).Warn("failed to send exit to subscriber")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Default.Unlock()
|
Default.Unlock()
|
||||||
return err
|
return err
|
||||||
|
@ -26,12 +26,13 @@ import (
|
|||||||
"github.com/containerd/containerd/sys"
|
"github.com/containerd/containerd/sys"
|
||||||
runc "github.com/containerd/go-runc"
|
runc "github.com/containerd/go-runc"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNoSuchProcess is returned when the process no longer exists
|
// ErrNoSuchProcess is returned when the process no longer exists
|
||||||
var ErrNoSuchProcess = errors.New("no such process")
|
var ErrNoSuchProcess = errors.New("no such process")
|
||||||
|
|
||||||
const bufferSize = 32
|
const bufferSize = 2048
|
||||||
|
|
||||||
// Reap should be called when the process receives an SIGCHLD. Reap will reap
|
// Reap should be called when the process receives an SIGCHLD. Reap will reap
|
||||||
// all exited processes and close their wait channels
|
// all exited processes and close their wait channels
|
||||||
@ -41,13 +42,20 @@ func Reap() error {
|
|||||||
Default.Lock()
|
Default.Lock()
|
||||||
for c := range Default.subscribers {
|
for c := range Default.subscribers {
|
||||||
for _, e := range exits {
|
for _, e := range exits {
|
||||||
c <- runc.Exit{
|
select {
|
||||||
|
case c <- runc.Exit{
|
||||||
Timestamp: now,
|
Timestamp: now,
|
||||||
Pid: e.Pid,
|
Pid: e.Pid,
|
||||||
Status: e.Status,
|
Status: e.Status,
|
||||||
|
}:
|
||||||
|
default:
|
||||||
|
logrus.WithFields(logrus.Fields{
|
||||||
|
"subscriber": c,
|
||||||
|
"pid": e.Pid,
|
||||||
|
"status": e.Status,
|
||||||
|
}).Warn("failed to send exit to subscriber")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Default.Unlock()
|
Default.Unlock()
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user