From 38c5c9cdfcb75e3a80d0c22d3991f62dad022f1e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 18 Nov 2017 17:12:57 +0300 Subject: [PATCH] Single background SP worker is allowed --- VERSION | 2 +- doc/news.ru.texi | 9 +++++++++ doc/news.texi | 9 +++++++++ src/cypherpunks.ru/nncp/sp.go | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c43e105..f304084 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.12 +0.13 diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 98804fb..5c5ee0d 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,15 @@ @node Новости @section Новости +@node Релиз 0.13 +@subsection Релиз 0.13 +@itemize +@item +В команде @command{nncp-call} разрешается иметь только одного +обработчика контрольной суммы в фоне. Это полезно когда тысячи маленьких +входящих пакетов могут создать много горутин. +@end itemize + @node Релиз 0.12 @subsection Релиз 0.12 @itemize diff --git a/doc/news.texi b/doc/news.texi index 8f36b4b..d673d80 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,15 @@ See also this page @ref{Новости, on russian}. +@node Release 0.13 +@section Release 0.13 +@itemize +@item +Single background checksum verifier worker is allowed in +@command{nncp-call}. This is helpful when thousands of small inbound +packets could create many goroutines. +@end itemize + @node Release 0.12 @section Release 0.12 @itemize diff --git a/src/cypherpunks.ru/nncp/sp.go b/src/cypherpunks.ru/nncp/sp.go index be84510..6daab72 100644 --- a/src/cypherpunks.ru/nncp/sp.go +++ b/src/cypherpunks.ru/nncp/sp.go @@ -55,6 +55,8 @@ var ( noise.CipherChaChaPoly, noise.HashBLAKE2b, ) + + spWorkersGroup sync.WaitGroup ) type SPType uint8 @@ -838,6 +840,8 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { continue } state.RUnlock() + spWorkersGroup.Wait() + spWorkersGroup.Add(1) go func() { if err := fd.Sync(); err != nil { state.ctx.LogE("sp-file", SdsAdd(sdsp, SDS{"err": err}), "sync") @@ -859,6 +863,7 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { state.Lock() delete(state.infosTheir, *file.Hash) state.Unlock() + spWorkersGroup.Done() go func() { state.payloads <- MarshalSP(SPTypeDone, SPDone{file.Hash}) }() -- 2.48.1