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
036e98c7
Commit
036e98c7
authored
Jul 06, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a3dc8357
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
go/neo/neonet/newlink.go
go/neo/neonet/newlink.go
+10
-11
No files found.
go/neo/neonet/newlink.go
View file @
036e98c7
...
...
@@ -80,7 +80,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
txWg
.
Done
()
}()
// rx handshake word
go
func
()
{
var
b
[
4
]
byte
...
...
@@ -100,9 +99,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
connClosed
:=
false
defer
func
()
{
// make sure our version is always sent on the wire, if possible,
// so that peer does not see just closed connection when on rx we see version mismatch
// so that peer does not see just closed connection when on rx we see version mismatch
.
//
// NOTE if cancelled tx goroutine will wake up without delay
// NOTE if cancelled tx goroutine will wake up without delay
.
txWg
.
Wait
()
// don't forget to close conn if returning with error + add handshake err context
...
...
@@ -114,7 +113,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
}
}()
for
i
:=
0
;
i
<
2
;
i
++
{
select
{
case
<-
ctx
.
Done
()
:
...
...
@@ -165,9 +163,9 @@ func ListenLink(net xnet.Networker, laddr string) (LinkListener, error) {
// The listener accepts only those connections that pass NEO protocol handshake.
func
NewLinkListener
(
inner
net
.
Listener
)
LinkListener
{
l
:=
&
linkListener
{
l
:
inner
,
acceptq
:
make
(
chan
linkAccepted
),
closed
:
make
(
chan
struct
{}),
l
:
inner
,
acceptq
:
make
(
chan
linkAccepted
),
closed
:
make
(
chan
struct
{}),
}
go
l
.
run
()
return
l
...
...
@@ -184,15 +182,16 @@ type LinkListener interface {
Accept
()
(
*
NodeLink
,
error
)
}
// linkListener implements LinkListener.
type
linkListener
struct
{
l
net
.
Listener
acceptq
chan
linkAccepted
closed
chan
struct
{}
closed
chan
struct
{}
}
type
linkAccepted
struct
{
link
*
NodeLink
err
error
link
*
NodeLink
err
error
}
func
(
l
*
linkListener
)
Close
()
error
{
...
...
@@ -252,7 +251,7 @@ func (l *linkListener) accept1(ctx context.Context, conn net.Conn, err error) (*
}
func
(
l
*
linkListener
)
Accept
()
(
*
NodeLink
,
error
)
{
select
{
select
{
case
<-
l
.
closed
:
// we know raw listener is already closed - return proper error about it
_
,
err
:=
l
.
l
.
Accept
()
...
...
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