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
8acb9b73
Commit
8acb9b73
authored
Aug 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cf76530c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
go/neo/server/storage.go
go/neo/server/storage.go
+21
-27
No files found.
go/neo/server/storage.go
View file @
8acb9b73
...
@@ -198,20 +198,17 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -198,20 +198,17 @@ 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
done/
cancelled.
// every new connection from master means talk over previous connection is cancelled.
// XXX check compatibility with py
// XXX check compatibility with py
type
accepted
struct
{
acceptq
:=
make
(
chan
*
neo
.
Conn
,
1
)
conn
*
neo
.
Conn
err
error
}
acceptq
:=
make
(
chan
accepted
,
1
)
go
func
()
{
go
func
()
{
for
{
for
{
conn
,
err
:=
Mlink
.
Accept
()
conn
,
err
:=
Mlink
.
Accept
()
acceptq
<-
accepted
{
conn
,
err
}
if
err
!=
nil
{
if
err
!=
nil
{
break
log
.
Error
(
ctx
,
err
)
return
}
}
acceptq
<-
conn
}
}
}()
}()
...
@@ -219,23 +216,23 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -219,23 +216,23 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
talkq
:=
make
(
chan
error
,
1
)
talkq
:=
make
(
chan
error
,
1
)
loop
:
loop
:
for
{
for
{
//
main worker which talks with master
over Mconn
//
one talk cycle for master to drive us
over Mconn
// puts error after talk finishes -> talkq
// puts error after talk finishes -> talkq
go
func
()
{
talk
:=
func
()
error
{
err
:=
func
()
error
{
// let master initialize us. If successful this ends with StartOperation command.
// let master initialize us. If successful this ends with StartOperation command.
err
:=
stor
.
m1initialize
(
ctx
,
Mconn
)
err
:=
stor
.
m1initialize
(
ctx
,
Mconn
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
ctx
,
err
)
return
err
}
// we got StartOperation command. Let master drive us during servicing phase.
err
=
stor
.
m1serve
(
ctx
,
Mconn
)
log
.
Error
(
ctx
,
err
)
log
.
Error
(
ctx
,
err
)
return
err
return
err
}()
}
talkq
<-
err
// we got StartOperation command. Let master drive us during servicing phase.
err
=
stor
.
m1serve
(
ctx
,
Mconn
)
log
.
Error
(
ctx
,
err
)
return
err
}
go
func
()
{
talkq
<-
talk
()
}()
}()
// talk finished / next connection / cancel
// talk finished / next connection / cancel
...
@@ -244,13 +241,10 @@ loop:
...
@@ -244,13 +241,10 @@ loop:
// XXX check for shutdown command
// XXX check for shutdown command
continue
loop
// retry from initializing
continue
loop
// retry from initializing
case
a
:=
<-
acceptq
:
case
conn
:=
<-
acceptq
:
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
lclose
(
ctx
,
Mconn
)
// wakeup/cancel current talk
if
a
.
err
!=
nil
{
return
a
.
err
}
<-
talkq
<-
talkq
Mconn
=
a
.
conn
Mconn
=
conn
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
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