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
a35297b6
Commit
a35297b6
authored
Dec 19, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
21902468
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
t/neo/connection.go
t/neo/connection.go
+10
-3
t/neo/connection_test.go
t/neo/connection_test.go
+2
-4
No files found.
t/neo/connection.go
View file @
a35297b6
...
...
@@ -67,6 +67,9 @@ type Conn struct {
connId
uint32
rxq
chan
*
PktBuf
// received packets for this Conn go here
txerr
chan
error
// transmit errors for this Conn go back here
// Conn has to be explicitly closed by user; it can also be closed by NodeLink.Close
closeOnce
sync
.
Once
closed
chan
struct
{}
}
...
...
@@ -142,8 +145,7 @@ func (nl *NodeLink) Close() error {
// XXX only interrupt, not close? Or allow multiple conn.Close() ?
conn
.
close
()
// XXX err -> errv
}
nl
.
connTab
=
nil
// XXX ok? vs panic on NewConn after close ?
nl
.
connTab
=
nil
// clear + mark closed
return
err
}
...
...
@@ -219,6 +221,9 @@ func (nl *NodeLink) newConn(connId uint32) *Conn {
func
(
nl
*
NodeLink
)
NewConn
()
*
Conn
{
nl
.
connMu
.
Lock
()
defer
nl
.
connMu
.
Unlock
()
if
nl
.
connTab
==
nil
{
panic
(
"NewConn() on closed node-link"
)
}
c
:=
nl
.
newConn
(
nl
.
nextConnId
)
nl
.
nextConnId
+=
2
return
c
...
...
@@ -340,7 +345,9 @@ func (c *Conn) Recv() (*PktBuf, error) {
// worker for Close() & co
func
(
c
*
Conn
)
close
()
{
c
.
closeOnce
.
Do
(
func
()
{
close
(
c
.
closed
)
// XXX better just close c.rxq + ??? for tx
})
}
// Close connection
...
...
t/neo/connection_test.go
View file @
a35297b6
...
...
@@ -138,7 +138,6 @@ func nodeLinkPipe() (nl1, nl2 *NodeLink) {
func
TestNodeLink
(
t
*
testing
.
T
)
{
// TODO catch exception -> add proper location from it -> t.Fatal (see git-backup)
println
(
"111"
)
nl1
,
nl2
:=
nodeLinkPipe
()
// Close vs recvPkt
...
...
@@ -198,7 +197,6 @@ func TestNodeLink(t *testing.T) {
// test channels on top of nodelink
println
(
"222"
)
nl1
,
nl2
=
nodeLinkPipe
()
// Close vs Recv
...
...
@@ -229,7 +227,6 @@ func TestNodeLink(t *testing.T) {
xwait
(
wg
)
// NodeLink.Close vs Conn.Send/Recv
println
(
"333"
)
c11
:=
nl1
.
NewConn
()
c12
:=
nl1
.
NewConn
()
wg
=
WorkGroup
()
...
...
@@ -249,9 +246,10 @@ func TestNodeLink(t *testing.T) {
tdelay
()
xclose
(
nl1
)
xwait
(
wg
)
xclose
(
c11
)
xclose
(
c12
)
xclose
(
nl2
)
// for completeness
println
(
"444"
)
/*
...
...
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