From d1550141d5c5057a86debd5fe4de2fd72ecc1cab Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 26 Jun 2021 15:12:53 +0300 Subject: [PATCH] Wait for background checksummers completion --- doc/news.ru.texi | 13 ++++++++++++- doc/news.texi | 11 +++++++++++ src/nncp.go | 2 +- src/sp.go | 8 ++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 69e3201..fc18fd5 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,17 @@ @node Новости @section Новости +@node Релиз 6.6.0 +@subsection Релиз 6.6.0 +@itemize + +@item +@command{nncp-daemon}, @command{nncp-call} и @command{nncp-caller} +ожидают завершения всех процессов фоновой проверки контрольных сумм, +после того как соединение закрыто. + +@end itemize + @node Релиз 6.5.0 @subsection Релиз 6.5.0 @itemize @@ -18,7 +29,7 @@ @item Убирать показ прогресса передачи пакетов когда вызов уже завершён в -@command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller}. +@command{nncp-daemon}, @command{nncp-call} и @command{nncp-caller}. @end itemize diff --git a/doc/news.texi b/doc/news.texi index 6fcf733..d0ef49e 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,17 @@ See also this page @ref{Новости, on russian}. +@node Release 6.6.0 +@section Release 6.6.0 +@itemize + +@item +@command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller} +commands wait for all background checksummers completion after +connection is finished. + +@end itemize + @node Release 6.5.0 @section Release 6.5.0 @itemize diff --git a/src/nncp.go b/src/nncp.go index a9af93c..1dfdb74 100644 --- a/src/nncp.go +++ b/src/nncp.go @@ -40,7 +40,7 @@ along with this program. If not, see .` const Base32Encoded32Len = 52 var ( - Version string = "6.5.0" + Version string = "6.6.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) ) diff --git a/src/sp.go b/src/sp.go index 0b039e6..00eaac6 100644 --- a/src/sp.go +++ b/src/sp.go @@ -65,7 +65,8 @@ var ( DefaultDeadline = 10 * time.Second PingTimeout = time.Minute - spCheckers = make(map[NodeId]*SPCheckerQueues) + spCheckers = make(map[NodeId]*SPCheckerQueues) + SPCheckersWg sync.WaitGroup ) type FdAndFullSize struct { @@ -282,6 +283,7 @@ func SPChecker(ctx *Ctx, nodeId *NodeId, appeared, checked chan *[32]byte) { {"Node", nodeId}, {"Pkt", pktName}, } + SPCheckersWg.Add(1) ctx.LogD("sp-checker", les, func(les LEs) string { return fmt.Sprintf("Checksumming %s/rx/%s", ctx.NodeName(nodeId), pktName) }) @@ -302,6 +304,7 @@ func SPChecker(ctx *Ctx, nodeId *NodeId, appeared, checked chan *[32]byte) { pktName, humanize.IBytes(uint64(size)), ) }) + SPCheckersWg.Done() go func(hsh *[32]byte) { checked <- hsh }(hshValue) } } @@ -1135,8 +1138,9 @@ func (state *SPState) Wait() { state.wg.Wait() close(state.payloads) close(state.pings) - state.dirUnlock() state.Duration = time.Now().Sub(state.started) + SPCheckersWg.Wait() + state.dirUnlock() state.RxSpeed = state.RxBytes state.TxSpeed = state.TxBytes rxDuration := int64(state.RxLastSeen.Sub(state.started).Seconds()) -- 2.44.0