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
213b9f14
Commit
213b9f14
authored
Apr 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3d0666ab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
16 deletions
+39
-16
go/neo/client.go
go/neo/client.go
+4
-1
go/neo/connection.go
go/neo/connection.go
+6
-4
go/neo/connection_test.go
go/neo/connection_test.go
+29
-11
No files found.
go/neo/client.go
View file @
213b9f14
...
...
@@ -87,7 +87,10 @@ func openClientByURL(u *url.URL) (zodb.IStorage, error) {
return
nil
,
err
}
conn
:=
storLink
.
NewConn
()
conn
,
err
:=
storLink
.
NewConn
()
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx ?
}
// TODO identify ourselves via conn
...
...
go/neo/connection.go
View file @
213b9f14
...
...
@@ -173,16 +173,18 @@ func (nl *NodeLink) newConn(connId uint32) *Conn {
}
// NewConn creates new connection on top of node-node link
func
(
nl
*
NodeLink
)
NewConn
()
*
Conn
{
func
(
nl
*
NodeLink
)
NewConn
()
(
*
Conn
,
error
)
{
nl
.
connMu
.
Lock
()
defer
nl
.
connMu
.
Unlock
()
if
nl
.
connTab
==
nil
{
// XXX -> error (because NodeLink can become "closed" due to IO errors ?
panic
(
"NewConn() on closed node-link"
)
if
atomic
.
LoadUint32
(
&
nl
.
closeCalled
)
!=
0
{
return
nil
,
ErrLinkClosed
}
return
nil
,
ErrLinkStopped
}
c
:=
nl
.
newConn
(
nl
.
nextConnId
)
nl
.
nextConnId
+=
2
return
c
return
c
,
nil
}
// close is worker for Close & friends.
...
...
go/neo/connection_test.go
View file @
213b9f14
...
...
@@ -60,6 +60,12 @@ func xclose(c io.Closer) {
exc
.
Raiseif
(
err
)
}
func
xnewconn
(
nl
*
NodeLink
)
*
Conn
{
c
,
err
:=
nl
.
NewConn
()
exc
.
Raiseif
(
err
)
return
c
}
func
xaccept
(
nl
*
NodeLink
)
*
Conn
{
c
,
err
:=
nl
.
Accept
()
exc
.
Raiseif
(
err
)
...
...
@@ -270,7 +276,7 @@ func TestNodeLink(t *testing.T) {
// Close vs Recv
nl1
,
nl2
=
_nodeLinkPipe
(
0
,
linkNoRecvSend
)
c
=
nl1
.
NewConn
(
)
c
=
xnewconn
(
nl1
)
wg
=
WorkGroup
()
wg
.
Gox
(
func
()
{
tdelay
()
...
...
@@ -286,7 +292,7 @@ func TestNodeLink(t *testing.T) {
// Close vs Send
nl1
,
nl2
=
_nodeLinkPipe
(
0
,
linkNoRecvSend
)
c
=
nl1
.
NewConn
(
)
c
=
xnewconn
(
nl1
)
wg
=
WorkGroup
()
wg
.
Gox
(
func
()
{
tdelay
()
...
...
@@ -300,8 +306,8 @@ func TestNodeLink(t *testing.T) {
xwait
(
wg
)
// NodeLink.Close vs Conn.Send/Recv
c11
:=
nl1
.
NewConn
(
)
c12
:=
nl1
.
NewConn
(
)
c11
:=
xnewconn
(
nl1
)
c12
:=
xnewconn
(
nl1
)
wg
=
WorkGroup
()
wg
.
Gox
(
func
()
{
pkt
,
err
:=
c11
.
Recv
()
...
...
@@ -325,9 +331,9 @@ func TestNodeLink(t *testing.T) {
// NodeLink.Close vs Conn.Send/Recv on another side
nl1
,
nl2
=
_nodeLinkPipe
(
0
,
linkNoRecvSend
)
c11
=
nl1
.
NewConn
(
)
c12
=
nl1
.
NewConn
(
)
c13
:=
nl1
.
NewConn
(
)
c11
=
xnewconn
(
nl1
)
c12
=
xnewconn
(
nl1
)
c13
:=
xnewconn
(
nl1
)
wg
=
WorkGroup
()
var
errRecv
error
wg
.
Gox
(
func
()
{
...
...
@@ -355,6 +361,12 @@ func TestNodeLink(t *testing.T) {
// XXX denoise vvv
// NewConn after NodeLink stop
c
,
err
=
nl1
.
NewConn
()
if
err
!=
ErrLinkStopped
{
t
.
Fatalf
(
"NewConn after NodeLink stop: %v"
,
err
)
}
// Recv/Send on another Conn
pkt
,
err
=
c13
.
Recv
()
if
!
(
pkt
==
nil
&&
err
==
errRecv
)
{
...
...
@@ -397,9 +409,15 @@ func TestNodeLink(t *testing.T) {
t
.
Fatalf
(
"Conn.Send after NodeLink stop: %v"
,
err
)
}
// NewConn after NodeLink close
c
,
err
=
nl1
.
NewConn
()
if
err
!=
ErrLinkClosed
{
t
.
Fatalf
(
"NewConn after NodeLink close: %v"
,
err
)
}
xclose
(
c11
)
xclose
(
c12
)
//
check
Recv/Send error after Close & NodeLink shutdown
// Recv/Send error after Close & NodeLink shutdown
pkt
,
err
=
c11
.
Recv
()
if
!
(
pkt
==
nil
&&
err
==
ErrClosedConn
)
{
t
.
Fatalf
(
"Conn.Recv after close and NodeLink close: pkt = %v err = %v"
,
pkt
,
err
)
...
...
@@ -429,7 +447,7 @@ func TestNodeLink(t *testing.T) {
xclose
(
c
)
})
c
=
nl1
.
NewConn
(
)
c
=
xnewconn
(
nl1
)
xsend
(
c
,
mkpkt
(
33
,
[]
byte
(
"ping"
)))
pkt
=
xrecv
(
c
)
xverifyPkt
(
pkt
,
c
.
connId
,
34
,
[]
byte
(
"pong"
))
...
...
@@ -477,8 +495,8 @@ func TestNodeLink(t *testing.T) {
}
})
c1
:=
nl1
.
NewConn
(
)
c2
:=
nl1
.
NewConn
(
)
c1
:=
xnewconn
(
nl1
)
c2
:=
xnewconn
(
nl1
)
xsend
(
c1
,
mkpkt
(
1
,
[]
byte
(
""
)))
xsend
(
c2
,
mkpkt
(
2
,
[]
byte
(
""
)))
...
...
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