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
6c092cf4
Commit
6c092cf4
authored
Jun 02, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c1e40bfe
Changes
1
Show 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 {
...
@@ -95,8 +95,8 @@ type listener struct {
}
}
// allocFreeEntry finds first free port and allocate network entry for it
// allocFreeEntry finds first free port and allocate
s
network entry for it
// must be called
under
.mu held
// must be called
with
.mu held
func
(
n
*
Network
)
allocFreeEntry
()
*
entry
{
func
(
n
*
Network
)
allocFreeEntry
()
*
entry
{
// find first free port if it was not specified
// find first free port if it was not specified
port
:=
0
port
:=
0
...
@@ -153,8 +153,8 @@ func (l *listener) Close() error {
...
@@ -153,8 +153,8 @@ func (l *listener) Close() error {
}
}
// Listen starts new listener
// Listen starts new listener
//
Ct either allocates new
port if laddr is "" or binds to laddr.
//
It either allocates free
port if laddr is "" or binds to laddr.
// Once listener is started Dials could connect to listen
er
address.
// Once listener is started Dials could connect to listen
ing
address.
// Connection requests created by Dials could be accepted via Accept.
// Connection requests created by Dials could be accepted via Accept.
func
(
n
*
Network
)
Listen
(
laddr
string
)
(
net
.
Listener
,
error
)
{
func
(
n
*
Network
)
Listen
(
laddr
string
)
(
net
.
Listener
,
error
)
{
lerr
:=
func
(
err
error
)
error
{
lerr
:=
func
(
err
error
)
error
{
...
@@ -243,20 +243,22 @@ func (n *Network) Dial(addr string) (net.Conn, error) {
...
@@ -243,20 +243,22 @@ func (n *Network) Dial(addr string) (net.Conn, error) {
}
}
n
.
mu
.
Lock
()
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
// XXX ok to defer here?
if
port
>=
len
(
n
.
entryv
)
{
if
port
>=
len
(
n
.
entryv
)
{
return
nil
,
derr
(
errConnRefused
)
// XXX merge with vvv
n
.
mu
.
Unlock
()
return
nil
,
derr
(
errConnRefused
)
}
}
e
:=
n
.
entryv
[
port
]
e
:=
n
.
entryv
[
port
]
if
e
==
nil
||
e
.
listener
==
nil
{
if
e
==
nil
||
e
.
listener
==
nil
{
return
nil
,
derr
(
errConnRefused
)
// XXX merge with ^^^
n
.
mu
.
Unlock
()
return
nil
,
derr
(
errConnRefused
)
}
}
l
:=
e
.
listener
l
:=
e
.
listener
// NOTE listener is not locking n.mu -> it is ok to send/receive under mu - FIXME not correct
// NOTE Accept is locking n.mu -> we must release n.mu before sending dial request
// FIXME -> Accept needs to register new connection under n.mu
n
.
mu
.
Unlock
()
resp
:=
make
(
chan
net
.
Conn
)
resp
:=
make
(
chan
net
.
Conn
)
select
{
select
{
case
<-
l
.
down
:
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