Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
3b5bb769
Commit
3b5bb769
authored
Apr 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8a8ddf1e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
go/neo/connection.go
go/neo/connection.go
+3
-2
go/neo/connection_test.go
go/neo/connection_test.go
+24
-8
No files found.
go/neo/connection.go
View file @
3b5bb769
...
...
@@ -92,6 +92,7 @@ type Conn struct {
}
// XXX include actual op (read/write/accept/connect) when there is an error ?
var
ErrLinkClosed
=
errors
.
New
(
"node link is closed"
)
// operations on closed NodeLink
var
ErrLinkDown
=
errors
.
New
(
"node link is down"
)
// e.g. due to IO error
var
ErrLinkNoListen
=
errors
.
New
(
"node link is not listening for incoming connections"
)
...
...
@@ -254,9 +255,9 @@ func (nl *NodeLink) Accept() (*Conn, error) {
select
{
case
<-
nl
.
down
:
if
atomic
.
LoadUint32
(
&
nl
.
closed
)
!=
0
{
return
nil
,
ErrLinkClosed
// XXX + op = Accept ?
return
nil
,
ErrLinkClosed
}
return
nil
,
ErrLinkDown
// XXX test
return
nil
,
ErrLinkDown
case
c
:=
<-
nl
.
acceptq
:
return
c
,
nil
...
...
go/neo/connection_test.go
View file @
3b5bb769
...
...
@@ -355,16 +355,28 @@ func TestNodeLink(t *testing.T) {
}
})
wg
.
Gox
(
func
()
{
conn
,
err
:=
nl2
.
Accept
()
if
!
(
conn
==
nil
&&
err
==
ErrLinkDown
)
{
exc
.
Raisef
(
"Accept after peer NodeLink shutdown: conn = %v err = %v"
,
conn
,
err
)
}
})
tdelay
()
xclose
(
nl1
)
xwait
(
wg
)
// XXX denoise vvv
// NewConn after NodeLink s
top
// NewConn after NodeLink s
hutdown
c
,
err
=
nl2
.
NewConn
()
if
err
!=
ErrLinkDown
{
t
.
Fatalf
(
"NewConn after NodeLink stop: %v"
,
err
)
t
.
Fatalf
(
"NewConn after NodeLink shutdown: %v"
,
err
)
}
// Accept after NodeLink shutdown
c
,
err
=
nl2
.
Accept
()
if
err
!=
ErrLinkDown
{
t
.
Fatalf
(
"Accept after NodeLink shutdown: conn = %v err = %v"
,
c
,
err
)
}
// Recv/Send on another Conn
...
...
@@ -380,11 +392,11 @@ func TestNodeLink(t *testing.T) {
// Recv/Send error on second call
pkt
,
err
=
c21
.
Recv
()
if
!
(
pkt
==
nil
&&
err
==
ErrLinkDown
)
{
t
.
Fatalf
(
"Conn.Recv after NodeLink s
top
: pkt = %v err = %v"
,
pkt
,
err
)
t
.
Fatalf
(
"Conn.Recv after NodeLink s
hutdown
: pkt = %v err = %v"
,
pkt
,
err
)
}
err
=
c22
.
Send
(
&
PktBuf
{[]
byte
(
"data"
)})
if
err
!=
ErrLinkDown
{
t
.
Fatalf
(
"Conn.Send after NodeLink s
top
: %v"
,
err
)
t
.
Fatalf
(
"Conn.Send after NodeLink s
hutdown
: %v"
,
err
)
}
xclose
(
c23
)
...
...
@@ -399,21 +411,25 @@ func TestNodeLink(t *testing.T) {
}
xclose
(
nl2
)
// Recv/Send error after NodeLink close
// Recv/Send
NewConn/Accept
error after NodeLink close
pkt
,
err
=
c21
.
Recv
()
if
!
(
pkt
==
nil
&&
err
==
ErrLinkClosed
)
{
t
.
Fatalf
(
"Conn.Recv after NodeLink s
top
: pkt = %v err = %v"
,
pkt
,
err
)
t
.
Fatalf
(
"Conn.Recv after NodeLink s
hutdown
: pkt = %v err = %v"
,
pkt
,
err
)
}
err
=
c22
.
Send
(
&
PktBuf
{[]
byte
(
"data"
)})
if
err
!=
ErrLinkClosed
{
t
.
Fatalf
(
"Conn.Send after NodeLink s
top
: %v"
,
err
)
t
.
Fatalf
(
"Conn.Send after NodeLink s
hutdown
: %v"
,
err
)
}
// NewConn after NodeLink close
c
,
err
=
nl2
.
NewConn
()
if
err
!=
ErrLinkClosed
{
t
.
Fatalf
(
"NewConn after NodeLink close: %v"
,
err
)
}
c
,
err
=
nl2
.
Accept
()
if
err
!=
ErrLinkClosed
{
t
.
Fatalf
(
"Accept after NodeLink close: %v"
,
err
)
}
xclose
(
c21
)
xclose
(
c22
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment