doc/download.texi | 4 ++++ doc/news.ru.texi | 10 ++++++++++ doc/news.texi | 9 +++++++++ ports/nncp/Makefile | 4 +--- ports/nncp/files/nncp-caller.in | 4 +--- ports/nncp/files/nncp-daemon.in | 4 +--- ports/nncp/files/nncp-toss.in | 4 +--- src/nncp.go | 2 +- src/sp.go | 16 +++++++++++++--- diff --git a/doc/download.texi b/doc/download.texi index 4277a5ea11929dec66b63cc7997b864fb8e7ae016435e534b0263649fb4e2712..96d01c014ffcc7978a3f0e96e30afbf71b9d19d0ed73a3232f0db3362f021a98 100644 --- a/doc/download.texi +++ b/doc/download.texi @@ -25,6 +25,10 @@ @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {link sign} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} @headitem Version @tab Date @tab Size @tab Tarball @tab SHA256 checksum +@item @ref{Release 6.3.0, 6.3.0} @tab 2021-04-14 @tab 1042 KiB +@tab @url{download/nncp-6.3.0.tar.xz, link} @url{download/nncp-6.3.0.tar.xz.sig, sign} +@tab @code{76C26A11 E3423540 BB7B8470 820176A3 5FCD0493 B21A872E C223EB94 43BA466B} + @item @ref{Release 6.2.1, 6.2.1} @tab 2021-03-26 @tab 1038 KiB @tab @url{download/nncp-6.2.1.tar.xz, link} @url{download/nncp-6.2.1.tar.xz.sig, sign} @tab @code{D9682D95 4D68025A F5B07516 258D9FFC DA29A4D7 E7E1635B E0C219A1 C5DDB067} diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 2f5d164be9ec32669696e0937aea9fc2d6c71f080d1bc9e8c76a5207314a2845..f1ba327762bedbe17ec5dee92f84d92dfd98dc846657deb5992123ecf9749063 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,16 @@ @node Новости @section Новости +@node Релиз 6.4.0 +@subsection Релиз 6.4.0 +@itemize + +@item +Исправлена возможная гонка в online протоколе, приводящая к падению +программы. + +@end itemize + @node Релиз 6.3.0 @subsection Релиз 6.3.0 @itemize diff --git a/doc/news.texi b/doc/news.texi index 32cc8b8996e77503ce53bacff0f67c9fc21ce99e1af23753dcfc4ca45fb0217a..d4cdc73ef7a2a8e8b87b6ac2d430d491bc346ee673b4f2ac44e74f110cddf7f1 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,15 @@ @unnumbered News See also this page @ref{Новости, on russian}. +@node Release 6.4.0 +@section Release 6.4.0 +@itemize + +@item +Fixed possible race in online protocol, that lead to panic. + +@end itemize + @node Release 6.3.0 @section Release 6.3.0 @itemize diff --git a/ports/nncp/Makefile b/ports/nncp/Makefile index 56efd5e6f85b20f329b08cec9a84a7c97621531bfbc6beb71ab33032423fbbb3..6eb6c077c8539fad7d4d7a47d2aef9d1dec0b494d139b664cddbfdd927dc82ba 100644 --- a/ports/nncp/Makefile +++ b/ports/nncp/Makefile @@ -1,7 +1,5 @@ -# $FreeBSD: $ - PORTNAME= nncp -DISTVERSION= 6.3.0 +DISTVERSION= 6.4.0 CATEGORIES= net MASTER_SITES= http://www.nncpgo.org/download/ diff --git a/ports/nncp/files/nncp-caller.in b/ports/nncp/files/nncp-caller.in index 0ca9c2d19803eee7f215dc7d00dbb2eedb222b1428fd24ff44b52169f7f3432a..187103301f277389631046571b4e3e6542274ad98281ca04e8339326863ffc00 100644 --- a/ports/nncp/files/nncp-caller.in +++ b/ports/nncp/files/nncp-caller.in @@ -1,7 +1,5 @@ #!/bin/sh -# -# $FreeBSD$ -# + # PROVIDE: nncp-caller # REQUIRE: DAEMON NETWORKING FILESYSTEMS # KEYWORD: shutdown diff --git a/ports/nncp/files/nncp-daemon.in b/ports/nncp/files/nncp-daemon.in index 485376d4fb5f4466ba982a3f729345c379b5e6243dacf5692570c1a48ee8fa33..6908e27f197a0d98784a0150590e8886e9b7b3097b11a2c88d7b6beb72940a1b 100644 --- a/ports/nncp/files/nncp-daemon.in +++ b/ports/nncp/files/nncp-daemon.in @@ -1,7 +1,5 @@ #!/bin/sh -# -# $FreeBSD$ -# + # PROVIDE: nncp-daemon # REQUIRE: DAEMON NETWORKING FILESYSTEMS # KEYWORD: shutdown diff --git a/ports/nncp/files/nncp-toss.in b/ports/nncp/files/nncp-toss.in index 775053454f6e8934f21147e6c4d186516b38677e84317fabc99dcdb1115df953..f2128783e995a64221c5decac312bd7b0f735b0f7177d9d8efdc0b14ba906637 100644 --- a/ports/nncp/files/nncp-toss.in +++ b/ports/nncp/files/nncp-toss.in @@ -1,7 +1,5 @@ #!/bin/sh -# -# $FreeBSD$ -# + # PROVIDE: nncp-toss # REQUIRE: DAEMON NETWORKING FILESYSTEMS # KEYWORD: shutdown diff --git a/src/nncp.go b/src/nncp.go index 05fa9c054a6f84a5992f127426c5d0b4749a2aa0dde7071bf2d74df2257e20f2..dc521689d050a4aa7cbc2f3732c92db3c13256bab8a457ca71fb38f19d53aacb 100644 --- a/src/nncp.go +++ b/src/nncp.go @@ -40,7 +40,7 @@ const Base32Encoded32Len = 52 var ( - Version string = "6.3.0" + Version string = "6.4.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) ) diff --git a/src/sp.go b/src/sp.go index 16fa163a00bb1a86b180101f8e5ba933867ebc59b55110118c1756d0a833062d..f95cebe7114baec147ce7b7f909098bd968360354c8c89ce3d13223d4b9ec1d1 100644 --- a/src/sp.go +++ b/src/sp.go @@ -233,6 +233,7 @@ listOnly bool onlyPkts map[[32]byte]bool writeSPBuf bytes.Buffer fds map[string]FdAndFullSize + fdsLock sync.RWMutex fileHashers map[string]*HasherAndOffset checkerQueues SPCheckerQueues sync.RWMutex @@ -669,11 +670,12 @@ return err } func (state *SPState) closeFd(pth string) { - s, exists := state.fds[pth] - delete(state.fds, pth) - if exists { + state.fdsLock.Lock() + if s, exists := state.fds[pth]; exists { + delete(state.fds, pth) s.fd.Close() } + state.fdsLock.Unlock() } func (state *SPState) StartWorkers( @@ -914,7 +916,9 @@ state.Node.Id.String(), string(TTx), Base32Codec.EncodeToString(freq.Hash[:]), ) + state.fdsLock.RLock() fdAndFullSize, exists := state.fds[pth] + state.fdsLock.RUnlock() if !exists { fd, err := os.Open(pth) if err != nil { @@ -931,7 +935,9 @@ }) return } fdAndFullSize = FdAndFullSize{fd: fd, fullSize: fi.Size()} + state.fdsLock.Lock() state.fds[pth] = fdAndFullSize + state.fdsLock.Unlock() } fd := fdAndFullSize.fd fullSize := fdAndFullSize.fullSize @@ -1352,7 +1358,9 @@ filePathPart := filePath + PartSuffix state.Ctx.LogD("sp-file-open", lesp, func(les LEs) string { return logMsg(les) + ": opening part" }) + state.fdsLock.RLock() fdAndFullSize, exists := state.fds[filePathPart] + state.fdsLock.RUnlock() var fd *os.File if exists { fd = fdAndFullSize.fd @@ -1368,7 +1376,9 @@ return logMsg(les) + ": opening part" }) return nil, err } + state.fdsLock.Lock() state.fds[filePathPart] = FdAndFullSize{fd: fd} + state.fdsLock.Unlock() if file.Offset == 0 { h, err := blake2b.New256(nil) if err != nil {