]> Cypherpunks.ru repositories - nncp.git/commitdiff
Kill progress bars when call is finished
authorSergey Matveev <stargrave@stargrave.org>
Sun, 30 May 2021 16:00:31 +0000 (19:00 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 30 May 2021 16:18:47 +0000 (19:18 +0300)
doc/news.ru.texi
doc/news.texi
src/progress.go
src/sp.go

index de6d127607704e090f00ef6d54fd6aaa664c46f5..e3087b218fb2aaa9e42a1b428676f1a0cbd3efab 100644 (file)
 @item
 Исправлено возможное игнорирование плохого кода возврата автоматического tosser.
 
+@item
+Убирать показ прогресса передачи пакетов когда вызов уже завершён в
+@command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller}.
+
 @end itemize
 
 @node Релиз 6.4.0
index 5bcd32c18c89fd1f6acee0b80a750a8b334013be..3097a0c98064b7fb3652a8a44a314b7266c2c266 100644 (file)
@@ -13,6 +13,10 @@ Fixed segfault in @command{nncp-daemon} when SP handshake did not succeed.
 @item
 Fixed possible bad return code ignoring in automatic tosser.
 
+@item
+Kill all packet transmission progress bars in @command{nncp-daemon},
+@command{nncp-call} and @command{nncp-caller} when call is finished.
+
 @end itemize
 
 @node Release 6.4.0
index dc55a000e01c4e12528dd682d15a44f093d82abc..945c57526419a2166cb20d3ea27057eff844da8b 100644 (file)
@@ -153,3 +153,13 @@ func Progress(prefix string, les LEs) {
                progressBarsLock.Unlock()
        }
 }
+
+func ProgressKill(pkt string) {
+       progressBarsLock.Lock()
+       pb, exists := progressBars[pkt]
+       if exists {
+               pb.Kill()
+               delete(progressBars, pkt)
+       }
+       progressBarsLock.Unlock()
+}
index 6d31375e137ff3a044d0bb5c1ad8ea4c481b4dd0..d7e4882b4a757f8863e08928912e950a4d87162d 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -236,6 +236,7 @@ type SPState struct {
        fdsLock        sync.RWMutex
        fileHashers    map[string]*HasherAndOffset
        checkerQueues  SPCheckerQueues
+       progressBars   map[string]struct{}
        sync.RWMutex
 }
 
@@ -441,6 +442,7 @@ func (state *SPState) StartI(conn ConnDeadlined) error {
        state.pings = make(chan struct{})
        state.infosTheir = make(map[[32]byte]*SPInfo)
        state.infosOurSeen = make(map[[32]byte]uint8)
+       state.progressBars = make(map[string]struct{})
        state.started = started
        state.rxLock = rxLock
        state.txLock = txLock
@@ -558,6 +560,7 @@ func (state *SPState) StartR(conn ConnDeadlined) error {
        state.pings = make(chan struct{})
        state.infosOurSeen = make(map[[32]byte]uint8)
        state.infosTheir = make(map[[32]byte]*SPInfo)
+       state.progressBars = make(map[string]struct{})
        state.started = started
        state.xxOnly = xxOnly
 
@@ -989,6 +992,7 @@ func (state *SPState) StartWorkers(
                                        LE{"FullSize", fullSize},
                                )
                                if state.Ctx.ShowPrgrs {
+                                       state.progressBars[pktName] = struct{}{}
                                        Progress("Tx", lesp)
                                }
                                state.Lock()
@@ -1002,6 +1006,9 @@ func (state *SPState) StartWorkers(
                                                } else {
                                                        state.queueTheir = state.queueTheir[:0]
                                                }
+                                               if state.Ctx.ShowPrgrs {
+                                                       delete(state.progressBars, pktName)
+                                               }
                                        } else {
                                                state.queueTheir[0].freq.Offset += uint64(len(buf))
                                        }
@@ -1138,6 +1145,9 @@ func (state *SPState) Wait() {
        if txDuration > 0 {
                state.TxSpeed = state.TxBytes / txDuration
        }
+       for pktName := range state.progressBars {
+               ProgressKill(pktName)
+       }
 }
 
 func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
@@ -1439,11 +1449,15 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        }
                        lesp = append(lesp, LE{"FullSize", fullsize})
                        if state.Ctx.ShowPrgrs {
+                               state.progressBars[pktName] = struct{}{}
                                Progress("Rx", lesp)
                        }
                        if fullsize != ourSize {
                                continue
                        }
+                       if state.Ctx.ShowPrgrs {
+                               delete(state.progressBars, pktName)
+                       }
                        logMsg = func(les LEs) string {
                                return fmt.Sprintf(
                                        "Got packet %s %d%% (%s / %s)",