bradleyfalzon / closecheck

Check for missing close method calls on objects that may require them - SEE EPILOGUE
Apache License 2.0
1 stars 0 forks source link

Caddy #5

Closed bradleyfalzon closed 8 years ago

bradleyfalzon commented 8 years ago

Caddy has an edge case where it's complaining something isn't closed, but technically it eventually is, and closecheck should handle this. This maybe too complex to handle, but ideally, closecheck should decide that it couldn't tell, so it shouldn't error.

I need to investigate why (probably as it's wrapped in a struct+map.

151     restartFds := make(map[string]restartPair)
152     for _, s := range i.servers {
153         gs, srvOk := s.server.(GracefulServer)
154         ln, lnOk := s.listener.(Listener)
155         if srvOk && lnOk {
156             restartFds[gs.Address()] = restartPair{server: gs, listener: ln}
157         }
158     }
...
163     // attempt to start new instance
164     err := startWithListenerFds(newCaddyfile, newInst, restartFds)
165     if err != nil {
166         return i, err
167     }

Eventually it is closed:

547         if gs, ok := s.(GracefulServer); ok && restartFds != nil {
548             addr := gs.Address()
549             if old, ok := restartFds[addr]; ok {
550                 file, err := old.listener.File()
551                 if err != nil {
552                     return err
553                 }
554                 ln, err = net.FileListener(file)
555                 if err != nil {
556                     return err
557                 }
558                 file.Close()
559             }
560         }