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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
9e1c3858
Commit
9e1c3858
authored
Aug 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f456cfaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
go/neo/server/storage.go
go/neo/server/storage.go
+14
-8
No files found.
go/neo/server/storage.go
View file @
9e1c3858
...
...
@@ -179,9 +179,11 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
Mlink
:=
Mconn
.
Link
()
// close Mlink on return / cancel
retch
:=
make
(
chan
struct
{})
defer
func
()
{
err2
:=
Mlink
.
Close
()
err
=
xerr
.
First
(
err
,
err2
)
close
(
retch
)
}()
// XXX add master UUID -> nodeTab ? or master will notify us with it himself ?
...
...
@@ -200,7 +202,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// 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.
// XXX recheck compatibility with py
acceptq
:=
make
(
chan
*
neo
.
Conn
,
1
)
acceptq
:=
make
(
chan
*
neo
.
Conn
)
go
func
()
{
for
{
conn
,
err
:=
Mlink
.
Accept
()
...
...
@@ -208,7 +210,11 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
log
.
Error
(
ctx
,
err
)
return
}
acceptq
<-
conn
select
{
case
acceptq
<-
conn
:
case
<-
retch
:
}
}
}()
...
...
@@ -243,18 +249,18 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
talkq
<-
talk
()
}()
//
talk finished / next connection
/ cancel
//
next connection / talk finished
/ cancel
select
{
case
conn
:=
<-
acceptq
:
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
<-
talkq
// wait till it finish
Mconn
=
conn
// proceed next cycle on accepted conn
case
err
=
<-
talkq
:
// XXX check for shutdown command
lclose
(
ctx
,
Mconn
)
Mconn
=
nil
// now wait for accept to get next Mconn
case
conn
:=
<-
acceptq
:
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
<-
talkq
Mconn
=
conn
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
}
...
...
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