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
2321a430
Commit
2321a430
authored
May 14, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
41d5c439
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
+26
-15
go/xcommon/xnet/lonet/lonet.go
go/xcommon/xnet/lonet/lonet.go
+26
-15
No files found.
go/xcommon/xnet/lonet/lonet.go
View file @
2321a430
...
...
@@ -106,11 +106,16 @@ type SubNetwork struct {
// registry of whole lonet network
registry
registry
// OS-level listener of this subnetwork.
// whenever connection to subnet's host is tried to be established it goes here.
oslistener
net
.
Listener
// big network lock for everything dynamic under SubNetwork
// (e.g. Host.socketv too) XXX
mu
sync
.
Mutex
hostMap
map
[
string
]
*
Host
// hostMap map[string]*Host // XXX lonet: not needed (registry instead)
// XXX track all hosts so SubNetwork.Shutdown shuts them down?
}
// Host represents named access point on Network XXX
...
...
@@ -197,32 +202,38 @@ func Join(ctx context.Context, network string) (_ *SubNetwork, err error) {
return
nil
,
err
}
// start OS listener
oslistener
,
err
:=
net
.
Listen
(
"tcp4"
,
"127.0.0.1:"
)
if
err
!=
nil
{
registry
.
Close
()
// XXX lclose?
return
nil
,
err
}
// joined ok
return
&
SubNetwork
{
network
:
network
,
registry
:
registry
,
hostMap
:
make
(
map
[
string
]
*
Host
),
network
:
network
,
registry
:
registry
,
oslistener
:
oslistener
,
// hostMap: make(map[string]*Host),
},
nil
}
// NewHost creates new lonet
network access poin
t with given name.
// NewHost creates new lonet
Hos
t with given name.
//
// Serving of created host will be done though SubNetwork via which it was
// created. XXX
//
// XXX errors
func
(
n
*
SubNetwork
)
NewHost
(
name
string
)
(
*
Host
,
error
)
{
// XXX redo for lonet
n
.
mu
.
Lock
()
defer
n
.
mu
.
Unlock
()
host
:=
n
.
hostMap
[
name
]
if
host
==
nil
{
host
=
&
Host
{
subnet
:
n
,
name
:
name
}
n
.
hostMap
[
name
]
=
host
// errHostDup if host name was already registered.
func
(
n
*
SubNetwork
)
NewHost
(
ctx
context
.
Context
,
name
string
)
(
*
Host
,
error
)
{
// announce host name to registry
err
:=
n
.
registry
.
Announce
(
ctx
,
name
,
n
.
oslistener
.
Addr
()
.
String
())
if
err
!=
nil
{
return
nil
,
err
// registry error has enough context
}
return
host
,
nil
// announced ok -> host can be created
return
&
Host
{
subnet
:
n
,
name
:
name
},
nil
}
// XXX Host.resolveAddr
...
...
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