From a72f277b5f8902be3abcd8ef0af2d5654e9197e0 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 6 Jul 2018 07:50:16 -0700 Subject: [PATCH] wait longer on an abnormal finish --- src/cleanup.go | 6 ++++-- src/client.go | 1 + src/models.go | 3 ++- src/utils.go | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cleanup.go b/src/cleanup.go index b4d8cb8..9c1fa58 100644 --- a/src/cleanup.go +++ b/src/cleanup.go @@ -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) diff --git a/src/client.go b/src/client.go index 1219d7a..dd89754 100644 --- a/src/client.go +++ b/src/client.go @@ -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 } diff --git a/src/models.go b/src/models.go index cea06f8..7efa878 100644 --- a/src/models.go +++ b/src/models.go @@ -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 diff --git a/src/utils.go b/src/utils.go index ce15210..d34949d 100644 --- a/src/utils.go +++ b/src/utils.go @@ -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()