From: Sergey Matveev Date: Sun, 30 May 2021 16:00:31 +0000 (+0300) Subject: Kill progress bars when call is finished X-Git-Tag: v6.5.0^2~2 X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=commitdiff_plain;h=41f1692751df06185e2ad681cf8650356ab6149c Kill progress bars when call is finished --- diff --git a/doc/news.ru.texi b/doc/news.ru.texi index de6d127..e3087b2 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -11,6 +11,10 @@ @item Исправлено возможное игнорирование плохого кода возврата автоматического tosser. +@item +Убирать показ прогресса передачи пакетов когда вызов уже завершён в +@command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller}. + @end itemize @node Релиз 6.4.0 diff --git a/doc/news.texi b/doc/news.texi index 5bcd32c..3097a0c 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -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 diff --git a/src/progress.go b/src/progress.go index dc55a00..945c575 100644 --- a/src/progress.go +++ b/src/progress.go @@ -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() +} diff --git a/src/sp.go b/src/sp.go index 6d31375..d7e4882 100644 --- 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)",