0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

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() { func (c *Croc) cleanup() {
c.cleanupTime = true c.cleanupTime = true
time.Sleep(250 * time.Millisecond) // race condition, wait for if !c.normalFinish {
time.Sleep(1000 * time.Millisecond) // race condition, wait for
// sending/receiving to finish // sending/receiving to finish
}
// erase all the croc files and their possible numbers // erase all the croc files and their possible numbers
for i := 0; i < 16; i++ { for i := 0; i < 16; i++ {
fname := c.crocFile + "." + strconv.Itoa(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.channel.transferTime = time.Since(c.cs.channel.startTransfer)
c.cs.Unlock() c.cs.Unlock()
log.Debug("leaving dialup") log.Debug("leaving dialup")
c.normalFinish = true
return return
} }

View file

@ -61,6 +61,7 @@ type Croc struct {
bothConnected bool bothConnected bool
// cleanupTime tells processes to close up // cleanupTime tells processes to close up
cleanupTime bool cleanupTime bool
normalFinish bool
} }
// Init will initialize the croc relay // 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) _, err = io.Copy(finished, fh)
if err != nil { if err != nil {
fh.Close()
return errors.Wrap(err, "CatFiles copy: ") return errors.Wrap(err, "CatFiles copy: ")
} }
fh.Close() fh.Close()