summaryrefslogtreecommitdiff
path: root/src/rhimportd/ctrlWatchDir.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-02 13:39:54 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-02 13:39:54 (GMT)
commitc69154b5c1e35ef038f00661e66fcb90113891bf (patch)
treecd3aed7f962e10d6b9a28e49f2a614de05cda32d /src/rhimportd/ctrlWatchDir.go
parenta9e805190242f5580036ff33fe7770af34fc7681 (diff)
improved handling of time.Ticker
Diffstat (limited to 'src/rhimportd/ctrlWatchDir.go')
-rw-r--r--src/rhimportd/ctrlWatchDir.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rhimportd/ctrlWatchDir.go b/src/rhimportd/ctrlWatchDir.go
index 1b08e62..14d1c1f 100644
--- a/src/rhimportd/ctrlWatchDir.go
+++ b/src/rhimportd/ctrlWatchDir.go
@@ -165,6 +165,8 @@ func watchDirHandler(conf *rhimport.Config, db *rddb.DBChan, ctx *rhimport.Conte
func watchDirRun(dir *os.File, conf *rhimport.Config, db *rddb.DBChan) {
rhl.Printf("watch-dir-ctrl: watching for files in %s", dir.Name())
+ t := time.NewTicker(1 * time.Second)
+ defer t.Stop()
for {
var err error
if _, err = dir.Seek(0, 0); err != nil {
@@ -199,8 +201,7 @@ func watchDirRun(dir *os.File, conf *rhimport.Config, db *rddb.DBChan) {
}
}
}
-
- time.Sleep(1 * time.Second)
+ <-t.C
}
}