]> Cypherpunks.ru repositories - nncp.git/commitdiff
Bad exit code if queues are not empty
authorSergey Matveev <stargrave@stargrave.org>
Wed, 2 Mar 2022 13:31:25 +0000 (16:31 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 2 Mar 2022 13:31:25 +0000 (16:31 +0300)
doc/news.ru.texi
doc/news.texi
src/call.go
src/sp.go

index abd4405b70bbd69f828e431ca0103e084f417e08..96031594d84c052c3fa291a0c39fe9689cb51377 100644 (file)
@@ -9,6 +9,10 @@
 @command{nncp-xfer} проверяет сходится ли контрольная сумма
 скопированного локально пакета и исходного.
 
+@item
+@command{nncp-call} имеет плохой код возврата если в очередях на приём и
+отправку остаются незаконченные задания.
+
 @item
 Появилась @command{nncp-ack} команда, которая отправляет явное
 подтверждение доставки пакета (ACK пакет). Это подтверждение удаляет
index c0a7912e30f643956b3ab2f0ad4a4527c82bf628..b9802ec2a1b320a5736e11d83325cb00e64fbed1 100644 (file)
@@ -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
index 295e7c8805c62eaee4cf0d3fd5051e4e86fb2251..95a70d6dcc502e03484c2385d8a665dde3b78bf8 100644 (file)
@@ -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 {
index 772d92c4d729bb4fbec8ba066ae67a3438e45807..eca9544945b1e0d734d6b21d692cce85dc68f372 100644 (file)
--- 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) {