Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
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
Stefane Fermigier
neo
Commits
6c092cf4
Commit
6c092cf4
authored
Jun 02, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c1e40bfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
go/xcommon/pipenet/pipenet.go
go/xcommon/pipenet/pipenet.go
+11
-9
No files found.
go/xcommon/pipenet/pipenet.go
View file @
6c092cf4
...
...
@@ -95,8 +95,8 @@ type listener struct {
}
// allocFreeEntry finds first free port and allocate network entry for it
// must be called
under
.mu held
// allocFreeEntry finds first free port and allocate
s
network entry for it
// must be called
with
.mu held
func
(
n
*
Network
)
allocFreeEntry
()
*
entry
{
// find first free port if it was not specified
port
:=
0
...
...
@@ -153,8 +153,8 @@ func (l *listener) Close() error {
}
// Listen starts new listener
//
Ct either allocates new
port if laddr is "" or binds to laddr.
// Once listener is started Dials could connect to listen
er
address.
//
It either allocates free
port if laddr is "" or binds to laddr.
// Once listener is started Dials could connect to listen
ing
address.
// Connection requests created by Dials could be accepted via Accept.
func
(
n
*
Network
)
Listen
(
laddr
string
)
(
net
.
Listener
,
error
)
{
lerr
:=
func
(
err
error
)
error
{
...
...
@@ -243,20 +243,22 @@ func (n *Network) Dial(addr string) (net.Conn, error) {
}
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
// XXX ok to defer here?
if
port
>=
len
(
n
.
entryv
)
{
return
nil
,
derr
(
errConnRefused
)
// XXX merge with vvv
n
.
mu
.
Unlock
()
return
nil
,
derr
(
errConnRefused
)
}
e
:=
n
.
entryv
[
port
]
if
e
==
nil
||
e
.
listener
==
nil
{
return
nil
,
derr
(
errConnRefused
)
// XXX merge with ^^^
n
.
mu
.
Unlock
()
return
nil
,
derr
(
errConnRefused
)
}
l
:=
e
.
listener
// NOTE listener is not locking n.mu -> it is ok to send/receive under mu - FIXME not correct
// FIXME -> Accept needs to register new connection under n.mu
// NOTE Accept is locking n.mu -> we must release n.mu before sending dial request
n
.
mu
.
Unlock
()
resp
:=
make
(
chan
net
.
Conn
)
select
{
case
<-
l
.
down
:
...
...
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