From 2570c230757df9e463ea072d9110564b53031ce3 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 2 Mar 2022 16:31:25 +0300 Subject: [PATCH] Bad exit code if queues are not empty --- doc/news.ru.texi | 4 ++++ doc/news.texi | 3 +++ src/call.go | 3 +-- src/sp.go | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index abd4405..9603159 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -9,6 +9,10 @@ @command{nncp-xfer} проверяет сходится ли контрольная сумма скопированного локально пакета и исходного. +@item +@command{nncp-call} имеет плохой код возврата если в очередях на приём и +отправку остаются незаконченные задания. + @item Появилась @command{nncp-ack} команда, которая отправляет явное подтверждение доставки пакета (ACK пакет). Это подтверждение удаляет diff --git a/doc/news.texi b/doc/news.texi index c0a7912..b9802ec 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -12,6 +12,9 @@ See also this page @ref{Новости, on russian}. @command{nncp-xfer} checks if locally copied packet's checksum differs from the source's one. +@item +@command{nncp-call} has bad return code if its queues contain unfinished jobs. + @item @command{nncp-ack} command appeared, that sends explicit packet receipt acknowledgement (ACK packet). That acknowledgement deletes referenced diff --git a/src/call.go b/src/call.go index 295e7c8..95a70d6 100644 --- a/src/call.go +++ b/src/call.go @@ -117,7 +117,7 @@ func (ctx *Ctx) CallNode( ctx.LogI("call-started", les, func(les LEs) string { return fmt.Sprintf("Connection to %s (%s)", node.Name, addr) }) - state.Wait() + isGood = state.Wait() ctx.LogI("call-finished", append( les, LE{"Duration", int64(state.Duration.Seconds())}, @@ -138,7 +138,6 @@ func (ctx *Ctx) CallNode( humanize.IBytes(uint64(state.TxSpeed)), ) }) - isGood = true conn.Close() break } else { diff --git a/src/sp.go b/src/sp.go index 772d92c..eca9544 100644 --- a/src/sp.go +++ b/src/sp.go @@ -1114,7 +1114,7 @@ func (state *SPState) StartWorkers( return nil } -func (state *SPState) Wait() { +func (state *SPState) Wait() bool { state.wg.Wait() close(state.payloads) close(state.pings) @@ -1130,12 +1130,15 @@ func (state *SPState) Wait() { if txDuration > 0 { state.TxSpeed = state.TxBytes / txDuration } + nothingLeft := len(state.queueTheir) == 0 for _, s := range state.fds { + nothingLeft = false s.fd.Close() } for pktName := range state.progressBars { ProgressKill(pktName) } + return nothingLeft } func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { -- 2.44.0