File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 29
29
// This state is terminal.
30
30
// This error will be returned if an atttempt is made to mutate the file
31
31
// descriptor store after stopping the upgrader.
32
- ErrUpgraderStopped = errors .New ("the upgrader has been marked as stopped" )
32
+ ErrUpgraderStopped = errors .New ("the upgrader has been marked as stopped" )
33
+ ErrClosingListeners = errors .New ("the upgrade completed, and listeners are being cleaned up" )
33
34
)
34
35
35
36
// Listener can be shared between processes.
@@ -131,7 +132,7 @@ type Fds struct {
131
132
l log15.Logger
132
133
}
133
134
134
- func (f * Fds ) String () string { // XXX here?
135
+ func (f * Fds ) String () string {
135
136
fds := f .copy ()
136
137
res := make ([]string , 0 , len (fds ))
137
138
for _ , fi := range fds {
@@ -463,6 +464,9 @@ func (f *Fds) copy() map[string]*fd {
463
464
// closeUnused closes unused FDs. It should be called
464
465
// while Fds is locked.
465
466
func (f * Fds ) closeUnused () error {
467
+ f .mu .Lock ()
468
+ defer f .mu .Unlock ()
469
+
466
470
var errs []error
467
471
for name , fd := range f .fds {
468
472
if ! fd .used {
Original file line number Diff line number Diff line change @@ -240,9 +240,9 @@ func (u *Upgrader) Ready() error {
240
240
}
241
241
242
242
// Now cleanup all old FDs while holding the lock
243
- // u.Fds.lockMutations(errors.New("closing old listeners") )
244
- // defer u.Fds.unlockMutations()
245
- // _ = u.Fds.closeUnused()
243
+ u .Fds .lockMutations (ErrClosingListeners )
244
+ defer u .Fds .unlockMutations ()
245
+ _ = u .Fds .closeUnused ()
246
246
247
247
return nil
248
248
}
You can’t perform that action at this time.
0 commit comments