Skip to content
Snippets Groups Projects
Unverified Commit a707057a authored by Wolfgang Welz's avatar Wolfgang Welz Committed by GitHub
Browse files

Fix: Write to closed neigbhor (#229)

* fix close order

* return closed error

* fix tests

* do not close send queue explicitly
parent 005edcd9
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,6 @@ func (n *Neighbor) IsOutbound() bool {
func (n *Neighbor) disconnect() (err error) {
n.disconnectOnce.Do(func() {
close(n.closing)
close(n.queue)
err = n.BufferedConnection.Close()
})
return
......@@ -140,7 +139,7 @@ func (n *Neighbor) readLoop() {
func (n *Neighbor) Write(b []byte) (int, error) {
l := len(b)
if l > maxPacketSize {
n.log.Errorw("message too large", "len", l, "max", maxPacketSize)
n.log.Panicw("message too large", "len", l, "max", maxPacketSize)
}
// add to queue
......
......@@ -35,19 +35,6 @@ func TestNeighborCloseTwice(t *testing.T) {
require.NoError(t, n.Close())
}
func TestNeighborWriteToClosed(t *testing.T) {
a, _, teardown := newPipe()
defer teardown()
n := newTestNeighbor("A", a)
n.Listen()
require.NoError(t, n.Close())
assert.Panics(t, func() {
_, _ = n.Write(testData)
})
}
func TestNeighborWrite(t *testing.T) {
a, b, teardown := newPipe()
defer teardown()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment