From: Sergey Matveev Date: Sun, 30 May 2021 16:04:29 +0000 (+0300) Subject: Fix files closing race when call is finished X-Git-Tag: v6.5.0^2 X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=commitdiff_plain;h=68079cc3371b6e9b5f429a404f51a4ef2bfdf65b Fix files closing race when call is finished --- diff --git a/doc/news.ru.texi b/doc/news.ru.texi index e3087b2..69e3201 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -11,6 +11,11 @@ @item Исправлено возможное игнорирование плохого кода возврата автоматического tosser. +@item +Исправлена гонка при закрытии файловых дескрипторов во время завершения +работы online протокола, которая могла привести к ошибке записи +принятого фрагмента пакета. + @item Убирать показ прогресса передачи пакетов когда вызов уже завершён в @command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller}. diff --git a/doc/news.texi b/doc/news.texi index 3097a0c..6fcf733 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 +Fixed race during file descriptors closing when online protocol call is +finished, that could lead to write error of received packet fragment. + @item Kill all packet transmission progress bars in @command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller} when call is finished. diff --git a/src/sp.go b/src/sp.go index 2dde928..0b039e6 100644 --- a/src/sp.go +++ b/src/sp.go @@ -258,11 +258,6 @@ func (state *SPState) SetDead() { for range state.pings { } }() - go func() { - for _, s := range state.fds { - s.fd.Close() - } - }() } func (state *SPState) NotAlive() bool { @@ -1152,6 +1147,9 @@ func (state *SPState) Wait() { if txDuration > 0 { state.TxSpeed = state.TxBytes / txDuration } + for _, s := range state.fds { + s.fd.Close() + } for pktName := range state.progressBars { ProgressKill(pktName) }