move inline interface out for readability
This commit is contained in:
parent
220ebb1f4f
commit
61aafa98f8
8
grace.go
8
grace.go
@ -51,6 +51,10 @@ type listener struct {
|
|||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type deadliner interface {
|
||||||
|
SetDeadline(t time.Time) error
|
||||||
|
}
|
||||||
|
|
||||||
// Allows for us to notice when the connection is closed.
|
// Allows for us to notice when the connection is closed.
|
||||||
type conn struct {
|
type conn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
@ -76,9 +80,7 @@ func (l *listener) Close() error {
|
|||||||
// Init provided sockets dont actually close so we trigger Accept to return
|
// Init provided sockets dont actually close so we trigger Accept to return
|
||||||
// by setting the deadline.
|
// by setting the deadline.
|
||||||
if os.Getppid() == 1 {
|
if os.Getppid() == 1 {
|
||||||
if ld, ok := l.Listener.(interface {
|
if ld, ok := l.Listener.(deadliner); ok {
|
||||||
SetDeadline(t time.Time) error
|
|
||||||
}); ok {
|
|
||||||
ld.SetDeadline(timeInPast)
|
ld.SetDeadline(timeInPast)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(os.Stderr, "init activated server did not have SetDeadline")
|
fmt.Fprintln(os.Stderr, "init activated server did not have SetDeadline")
|
||||||
|
Loading…
Reference in New Issue
Block a user