]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/sp.go
Fix files closing race when call is finished
[nncp.git] / src / sp.go
index 2dde928eaeecff5a84841cb0d8889a1a8306793c..0b039e6bffb9f80f6eecff80b36d8ce985552215 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -258,11 +258,6 @@ func (state *SPState) SetDead() {
                for range state.pings {
                }
        }()
-       go func() {
-               for _, s := range state.fds {
-                       s.fd.Close()
-               }
-       }()
 }
 
 func (state *SPState) NotAlive() bool {
@@ -1152,6 +1147,9 @@ func (state *SPState) Wait() {
        if txDuration > 0 {
                state.TxSpeed = state.TxBytes / txDuration
        }
+       for _, s := range state.fds {
+               s.fd.Close()
+       }
        for pktName := range state.progressBars {
                ProgressKill(pktName)
        }