Commit 72aea8ce authored by Kirill Smelkov's avatar Kirill Smelkov

go/{zeo,neo}: Don't tolerate if a packet reads only partially

If remote peer closes the link half-way of packet data - turn EOF into
ErrUnexpectedEOF.
parent 2babcd59
...@@ -91,6 +91,7 @@ import ( ...@@ -91,6 +91,7 @@ import (
"time" "time"
"lab.nexedi.com/kirr/neo/go/internal/packed" "lab.nexedi.com/kirr/neo/go/internal/packed"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/neo/go/neo/proto" "lab.nexedi.com/kirr/neo/go/neo/proto"
"github.com/someonegg/gocontainer/rbuf" "github.com/someonegg/gocontainer/rbuf"
...@@ -1209,7 +1210,7 @@ func (nl *NodeLink) recvPkt() (*pktBuf, error) { ...@@ -1209,7 +1210,7 @@ func (nl *NodeLink) recvPkt() (*pktBuf, error) {
if n < pktLen { if n < pktLen {
δn, err := io.ReadAtLeast(nl.peerLink, data[n:], pktLen - n) δn, err := io.ReadAtLeast(nl.peerLink, data[n:], pktLen - n)
if err != nil { if err != nil {
return nil, err return nil, xio.NoEOF(err)
} }
n += δn n += δn
} }
......
...@@ -30,6 +30,8 @@ import ( ...@@ -30,6 +30,8 @@ import (
"net" "net"
"sync" "sync"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"github.com/someonegg/gocontainer/rbuf" "github.com/someonegg/gocontainer/rbuf"
"lab.nexedi.com/kirr/go123/xbytes" "lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
...@@ -417,7 +419,7 @@ func (zl *zLink) recvPkt() (*pktBuf, error) { ...@@ -417,7 +419,7 @@ func (zl *zLink) recvPkt() (*pktBuf, error) {
if n < pktLen { if n < pktLen {
δn, err := io.ReadAtLeast(zl.link, data[n:], pktLen - n) δn, err := io.ReadAtLeast(zl.link, data[n:], pktLen - n)
if err != nil { if err != nil {
return nil, err return nil, xio.NoEOF(err)
} }
n += δn n += δn
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment