]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' v6.4.0
authorSergey Matveev <stargrave@stargrave.org>
Thu, 22 Apr 2021 14:33:49 +0000 (17:33 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 22 Apr 2021 14:33:49 +0000 (17:33 +0300)
doc/download.texi
doc/news.ru.texi
doc/news.texi
ports/nncp/Makefile
ports/nncp/files/nncp-caller.in
ports/nncp/files/nncp-daemon.in
ports/nncp/files/nncp-toss.in
src/nncp.go
src/sp.go

index b0e4465792e853966eebebba55798cabf00a4e6b..4d6f19606c22420fdd224a4de6235fe349dcb222 100644 (file)
@@ -25,6 +25,10 @@ Tarballs include all necessary required libraries:
 @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}
index ea1c700ff4acaf21a2e0ee9cdc851d999c896d4e..aa4f62ff76387a603924cd28342fcd39b94d85cd 100644 (file)
@@ -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
index 87be65235774f1bbfe1be404a27ae220f6b5d9a0..67340e2ebb66abfe81239334ad790162e6b9fb0c 100644 (file)
@@ -3,6 +3,15 @@
 
 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
index e2a7e5d9f4ec3f882bf160b9666638c174cad78a..c398830cbb65c6a315e27e4719bfe652eac4a8ff 100644 (file)
@@ -1,7 +1,5 @@
-# $FreeBSD: $
-
 PORTNAME=      nncp
-DISTVERSION=   6.3.0
+DISTVERSION=   6.4.0
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
 
index 0ab5492d02d7bd1e9f59a4505a511c3c8bace07c..3ae65fb03ee2547750500efb63eff5a60d596ca1 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/sh
-#
-# $FreeBSD$
-#
+
 # PROVIDE: nncp-caller
 # REQUIRE: DAEMON NETWORKING FILESYSTEMS
 # KEYWORD: shutdown
index fdc10649661025d573a83e84431dce2573a3a8a4..0e9b6dcc7120311f96b21f7d942a2ec7b6f33505 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/sh
-#
-# $FreeBSD$
-#
+
 # PROVIDE: nncp-daemon
 # REQUIRE: DAEMON NETWORKING FILESYSTEMS
 # KEYWORD: shutdown
index 6fbe5469462f136c39ed4ef377bbbae3cf5018b6..99dc6fc79204cf46fcd0e5279631ca2d6df1e746 100644 (file)
@@ -1,7 +1,5 @@
 #!/bin/sh
-#
-# $FreeBSD$
-#
+
 # PROVIDE: nncp-toss
 # REQUIRE: DAEMON NETWORKING FILESYSTEMS
 # KEYWORD: shutdown
index 12edaa40f73c52cf37e2b745a42f99455eedb7a9..7c1b7c576dd04da62f3e61662f21760ba01fe0e9 100644 (file)
@@ -40,7 +40,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 const Base32Encoded32Len = 52
 
 var (
-       Version string = "6.3.0"
+       Version string = "6.4.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )
index e6e4900a47052ceb81098d3e8d0f453889c48e7a..6d31375e137ff3a044d0bb5c1ad8ea4c481b4dd0 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -233,6 +233,7 @@ type SPState struct {
        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 @@ func (state *SPState) StartR(conn ConnDeadlined) error {
 }
 
 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 @@ func (state *SPState) StartWorkers(
                                        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 @@ func (state *SPState) StartWorkers(
                                                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 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        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 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                                        })
                                        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 {