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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
edfc431e
Commit
edfc431e
authored
Dec 20, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f9293ea7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
3 deletions
+55
-3
t/neo/connection.go
t/neo/connection.go
+1
-1
t/neo/connection_test.go
t/neo/connection_test.go
+54
-2
No files found.
t/neo/connection.go
View file @
edfc431e
...
...
@@ -411,7 +411,7 @@ func (c *Conn) close() {
// Close connection
// Any blocked Send() or Recv() will be unblocked and return error
// XXX Send() - if started - will first complete (not to break framing)
// XXX Send() - if started - will first complete (not to break framing)
XXX <- in background
func
(
c
*
Conn
)
Close
()
error
{
// XXX do we need error here?
// adjust nodeLink.connTab
c
.
nodeLink
.
connMu
.
Lock
()
...
...
t/neo/connection_test.go
View file @
edfc431e
...
...
@@ -263,6 +263,7 @@ func TestNodeLink(t *testing.T) {
xclose
(
nl2
)
// for completeness
// Conn accept + exchange
println
(
"000"
)
nl1
,
nl2
=
nodeLinkPipe
()
nl2
.
HandleNewConn
(
func
(
c
*
Conn
)
{
// TODO raised err -> errch
...
...
@@ -279,9 +280,60 @@ func TestNodeLink(t *testing.T) {
pkt2
:=
xrecv
(
c1
)
xverifyPkt
(
pkt2
,
c1
.
connId
,
34
,
[]
byte
(
"pong"
))
// test 2 channels with replies comming in reversed time order
println
(
"111"
)
order
:=
map
[
uint16
]
struct
{
// "order" in which to process requests
start
chan
int
// processing starts when start chan is ready
next
uint16
// after processing this switch to next
}{
2
:
{
make
(
chan
int
),
1
},
1
:
{
make
(
chan
int
),
0
},
}
go
func
()
{
order
[
2
]
.
start
<-
0
}()
println
(
"aaa"
)
c2
:=
nl1
.
NewConn
()
nl2
.
HandleNewConn
(
func
(
c
*
Conn
)
{
pkt
:=
xrecv
(
c
)
n
:=
ntoh16
(
pkt
.
Header
()
.
MsgCode
)
x
:=
order
[
n
]
// wait before it is our turn & echo pkt back
<-
x
.
start
xsend
(
c
,
pkt
)
// tell next it can start
if
x
.
next
!=
0
{
order
[
x
.
next
]
.
start
<-
0
}
})
xsend
(
c1
,
mkpkt
(
1
,
[]
byte
(
""
)))
xsend
(
c2
,
mkpkt
(
2
,
[]
byte
(
""
)))
println
(
"bbb"
)
wg
=
WorkGroup
()
echoTest
:=
func
(
c
*
Conn
,
msgCode
uint16
)
func
()
{
return
func
()
{
/*
pkt := mkpkt(msgCode, []byte(""))
xsend(c, pkt)
*/
pkt2
:=
xrecv
(
c
)
println
(
"recv"
,
msgCode
)
xverifyPkt
(
pkt2
,
c
.
connId
,
msgCode
,
[]
byte
(
""
))
}
}
wg
.
Gox
(
echoTest
(
c1
,
1
))
wg
.
Gox
(
echoTest
(
c2
,
2
))
println
(
"ccc"
)
xwait
(
wg
)
println
(
"ddd"
)
xclose
(
c1
)
xclose
(
c2
)
xclose
(
nl1
)
xclose
(
nl2
)
// test 2 channels with replies comming in reversed time order
}
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