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
df5aca5b
Commit
df5aca5b
authored
Aug 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9e1c3858
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
9 deletions
+48
-9
go/neo/connection.go
go/neo/connection.go
+27
-0
go/neo/server/storage.go
go/neo/server/storage.go
+21
-9
No files found.
go/neo/connection.go
View file @
df5aca5b
...
@@ -823,6 +823,33 @@ func (l *linkListener) Addr() net.Addr {
...
@@ -823,6 +823,33 @@ func (l *linkListener) Addr() net.Addr {
return
l
.
l
.
Addr
()
return
l
.
l
.
Addr
()
}
}
/*
XXX do if this is needed in a second place besides talkMaster1
// ---- Listen for single Conn over NodeLink use-cases ----
// XXX
func ListenSingleConn(link *NodeLink) ConnListener {
l := &listen1conn{link}
// XXX go ...
return l
}
// ConnListener XXX ...
type ConnListener interface {
// XXX +Close, Addr ?
// Accept returns new connection multiplexed over NodeLink
Accept() (*Conn, error)
}
type listen1conn struct {
link *NodeLink
}
func ...
*/
// ---- for convenience: Conn -> NodeLink & local/remote link addresses ----
// ---- for convenience: Conn -> NodeLink & local/remote link addresses ----
// LocalAddr returns local address of the underlying link to peer.
// LocalAddr returns local address of the underlying link to peer.
...
...
go/neo/server/storage.go
View file @
df5aca5b
...
@@ -202,18 +202,21 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -202,18 +202,21 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// accept next connection from master. only 1 connection is served at any given time.
// accept next connection from master. only 1 connection is served at any given time.
// every new connection from master means talk over previous connection is cancelled.
// every new connection from master means talk over previous connection is cancelled.
// XXX recheck compatibility with py
// XXX recheck compatibility with py
acceptq
:=
make
(
chan
*
neo
.
Conn
)
type
accepted
struct
{
conn
*
neo
.
Conn
;
err
error
}
acceptq
:=
make
(
chan
accepted
)
go
func
()
{
go
func
()
{
for
{
for
{
conn
,
err
:=
Mlink
.
Accept
()
conn
,
err
:=
Mlink
.
Accept
()
if
err
!=
nil
{
log
.
Error
(
ctx
,
err
)
return
}
select
{
select
{
case
acceptq
<-
conn
:
case
acceptq
<-
accepted
{
conn
,
err
}
:
case
<-
retch
:
case
<-
retch
:
return
}
if
err
!=
nil
{
log
.
Error
(
ctx
,
err
)
return
}
}
}
}
}()
}()
...
@@ -222,9 +225,15 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -222,9 +225,15 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
talkq
:=
make
(
chan
error
,
1
)
talkq
:=
make
(
chan
error
,
1
)
for
{
for
{
// wait for next connection from master if talk over previous one finished.
// wait for next connection from master if talk over previous one finished.
// XXX rafactor all this into SingleTalker ? (XXX ServeSingle ?)
if
Mconn
==
nil
{
if
Mconn
==
nil
{
select
{
select
{
case
Mconn
=
<-
acceptq
:
case
a
:=
<-
acceptq
:
if
a
.
err
!=
nil
{
return
a
.
err
}
Mconn
=
a
.
conn
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
return
ctx
.
Err
()
}
}
...
@@ -251,10 +260,13 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -251,10 +260,13 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// next connection / talk finished / cancel
// next connection / talk finished / cancel
select
{
select
{
case
conn
:=
<-
acceptq
:
case
a
:=
<-
acceptq
:
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
<-
talkq
// wait till it finish
<-
talkq
// wait till it finish
Mconn
=
conn
// proceed next cycle on accepted conn
if
a
.
err
!=
nil
{
return
a
.
err
}
Mconn
=
a
.
conn
// proceed next cycle on accepted conn
case
err
=
<-
talkq
:
case
err
=
<-
talkq
:
// XXX check for shutdown command
// XXX check for shutdown command
...
...
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