wait longer on an abnormal finish

This commit is contained in:
Zack Scholl 2018-07-06 07:50:16 -07:00
parent d906630f3a
commit c01bc56079
4 changed files with 8 additions and 3 deletions

View File

@ -8,8 +8,10 @@ import (
func (c *Croc) cleanup() {
c.cleanupTime = true
time.Sleep(250 * time.Millisecond) // race condition, wait for
// sending/receiving to finish
if !c.normalFinish {
time.Sleep(1000 * time.Millisecond) // race condition, wait for
// sending/receiving to finish
}
// erase all the croc files and their possible numbers
for i := 0; i < 16; i++ {
fname := c.crocFile + "." + strconv.Itoa(i)

View File

@ -503,6 +503,7 @@ func (c *Croc) dialUp() (err error) {
c.cs.channel.transferTime = time.Since(c.cs.channel.startTransfer)
c.cs.Unlock()
log.Debug("leaving dialup")
c.normalFinish = true
return
}

View File

@ -60,7 +60,8 @@ type Croc struct {
// bothConnected
bothConnected bool
// cleanupTime tells processes to close up
cleanupTime bool
cleanupTime bool
normalFinish bool
}
// Init will initialize the croc relay

View File

@ -32,6 +32,7 @@ func catFiles(files []string, outfile string, remove bool) error {
}
_, err = io.Copy(finished, fh)
if err != nil {
fh.Close()
return errors.Wrap(err, "CatFiles copy: ")
}
fh.Close()