]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/sp.go
fsnotify usage
[nncp.git] / src / sp.go
index 3de629b59b5108b9c2d49bae226f9041cb8ccbe9..1f2e91504dfd7d71c15cb86787fc68afeafb52fb 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -23,6 +23,7 @@ import (
        "errors"
        "fmt"
        "io"
+       "log"
        "os"
        "path/filepath"
        "sort"
@@ -772,14 +773,21 @@ func (state *SPState) StartWorkers(
        if !state.listOnly && (state.xxOnly == "" || state.xxOnly == TTx) {
                state.wg.Add(1)
                go func() {
-                       ticker := time.NewTicker(time.Second)
+                       dw, err := state.Ctx.NewDirWatcher(
+                               filepath.Join(state.Ctx.Spool, state.Node.Id.String(), string(TTx)),
+                               time.Second,
+                       )
+                       if err != nil {
+                               state.Ctx.LogE("sp-queue-dir-watch", les, err, logMsg)
+                               log.Fatalln(err)
+                       }
                        for {
                                select {
                                case <-state.isDead:
+                                       dw.Close()
                                        state.wg.Done()
-                                       ticker.Stop()
                                        return
-                               case <-ticker.C:
+                               case <-dw.C:
                                        for _, payload := range state.Ctx.infosOur(
                                                state.Node.Id,
                                                state.Nice,