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
0fa96338
Commit
0fa96338
authored
Sep 14, 2017
by
Kirill Smelkov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Clarified Request.Close semantics - tests working again
parent
443e0199
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
87 deletions
+121
-87
go/neo/client/client.go
go/neo/client/client.go
+30
-20
go/neo/connection.go
go/neo/connection.go
+3
-1
go/neo/server/master.go
go/neo/server/master.go
+2
-1
go/neo/server/storage.go
go/neo/server/storage.go
+86
-65
No files found.
go/neo/client/client.go
View file @
0fa96338
...
@@ -281,8 +281,17 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) (err error
...
@@ -281,8 +281,17 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) (err error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
c
.
recvMaster1
(
ctx
,
req
)
req
.
Close
()
req
.
Close
()
if
err
!=
nil
{
return
err
}
}
}
// recvMaster1 handles 1 message from master
func
(
c
*
Client
)
recvMaster1
(
ctx
context
.
Context
,
req
neo
.
Request
)
error
{
c
.
node
.
StateMu
.
Lock
()
c
.
node
.
StateMu
.
Lock
()
switch
msg
:=
req
.
Msg
.
(
type
)
{
switch
msg
:=
req
.
Msg
.
(
type
)
{
...
@@ -309,7 +318,8 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) (err error
...
@@ -309,7 +318,8 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) (err error
opready
:=
c
.
updateOperational
()
opready
:=
c
.
updateOperational
()
c
.
node
.
StateMu
.
Unlock
()
c
.
node
.
StateMu
.
Unlock
()
opready
()
opready
()
}
return
nil
}
}
func
(
c
*
Client
)
initFromMaster
(
ctx
context
.
Context
,
mlink
*
neo
.
NodeLink
)
(
err
error
)
{
func
(
c
*
Client
)
initFromMaster
(
ctx
context
.
Context
,
mlink
*
neo
.
NodeLink
)
(
err
error
)
{
...
...
go/neo/connection.go
View file @
0fa96338
...
@@ -1427,6 +1427,8 @@ func (c *Conn) Ask(req Msg, resp Msg) error {
...
@@ -1427,6 +1427,8 @@ func (c *Conn) Ask(req Msg, resp Msg) error {
//
//
// No Send or Recv must be in flight.
// No Send or Recv must be in flight.
// The caller must not use c after call to close - the connection is returned to freelist.
// The caller must not use c after call to close - the connection is returned to freelist.
//
// XXX must be called only once.
func
(
c
*
Conn
)
lightClose
()
{
func
(
c
*
Conn
)
lightClose
()
{
nl
:=
c
.
link
nl
:=
c
.
link
nl
.
connMu
.
Lock
()
nl
.
connMu
.
Lock
()
...
@@ -1460,7 +1462,7 @@ func (link *NodeLink) Recv1() (Request, error) {
...
@@ -1460,7 +1462,7 @@ func (link *NodeLink) Recv1() (Request, error) {
// NOTE serveRecv guaranty that when a conn is accepted, there is 1 message in conn.rxq
// NOTE serveRecv guaranty that when a conn is accepted, there is 1 message in conn.rxq
msg
,
err
:=
conn
.
Recv
()
// XXX directly from <-rxq
msg
,
err
:=
conn
.
Recv
()
// XXX directly from <-rxq
if
err
!=
nil
{
if
err
!=
nil
{
conn
.
Close
()
// XXX -> conn.
release
conn
.
Close
()
// XXX -> conn.
lightClose()
return
Request
{},
err
return
Request
{},
err
}
}
...
...
go/neo/server/master.go
View file @
0fa96338
...
@@ -860,7 +860,7 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
...
@@ -860,7 +860,7 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
//if err != nil {
//if err != nil {
// return err
// return err
//}
//}
//req.Close()
//req.Close()
XXX must be after req handling
//switch msg := req.Msg.(type) {
//switch msg := req.Msg.(type) {
//case *neo.NotifyReady:
//case *neo.NotifyReady:
// // ok
// // ok
...
@@ -910,6 +910,7 @@ func (m *Master) serveClient(ctx context.Context, cli *neo.Node) (err error) {
...
@@ -910,6 +910,7 @@ func (m *Master) serveClient(ctx context.Context, cli *neo.Node) (err error) {
resp
:=
m
.
serveClient1
(
ctx
,
req
.
Msg
)
resp
:=
m
.
serveClient1
(
ctx
,
req
.
Msg
)
err
=
req
.
Reply
(
resp
)
err
=
req
.
Reply
(
resp
)
req
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
go/neo/server/storage.go
View file @
0fa96338
...
@@ -238,16 +238,32 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
...
@@ -238,16 +238,32 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
err
=
stor
.
m1initialize1
(
ctx
,
req
)
if
err
==
cmdStart
{
// start - transition to serve
return
&
req
,
nil
}
req
.
Close
()
if
err
!=
nil
{
return
nil
,
err
}
}
}
var
cmdStart
=
errors
.
New
(
"start requested"
)
// m1initialize1 handles one message from master from under m1initialize
func
(
stor
*
Storage
)
m1initialize1
(
ctx
context
.
Context
,
req
neo
.
Request
)
error
{
// XXX vvv move Send out of reply preparing logic
// XXX vvv move Send out of reply preparing logic
var
err
error
switch
msg
:=
req
.
Msg
.
(
type
)
{
switch
msg
:=
req
.
Msg
.
(
type
)
{
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
case
*
neo
.
StartOperation
:
case
*
neo
.
StartOperation
:
// ok, transition to serve
// ok, transition to serve
return
&
req
,
nil
return
cmdStart
case
*
neo
.
Recovery
:
case
*
neo
.
Recovery
:
err
=
req
.
Reply
(
&
neo
.
AnswerRecovery
{
err
=
req
.
Reply
(
&
neo
.
AnswerRecovery
{
...
@@ -271,7 +287,7 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
...
@@ -271,7 +287,7 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
lastTid
,
zerr1
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastTid
,
zerr1
:=
stor
.
zstor
.
LastTid
(
ctx
)
lastOid
,
zerr2
:=
stor
.
zstor
.
LastOid
(
ctx
)
lastOid
,
zerr2
:=
stor
.
zstor
.
LastOid
(
ctx
)
if
zerr
:=
xerr
.
First
(
zerr1
,
zerr2
);
zerr
!=
nil
{
if
zerr
:=
xerr
.
First
(
zerr1
,
zerr2
);
zerr
!=
nil
{
return
nil
,
zerr
// XXX send the error to M
return
zerr
// XXX send the error to M
}
}
err
=
req
.
Reply
(
&
neo
.
AnswerLastIDs
{
LastTid
:
lastTid
,
LastOid
:
lastOid
})
err
=
req
.
Reply
(
&
neo
.
AnswerLastIDs
{
LastTid
:
lastTid
,
LastOid
:
lastOid
})
...
@@ -292,12 +308,7 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
...
@@ -292,12 +308,7 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
}
}
// XXX move req.Reply here and ^^^ only prepare reply
// XXX move req.Reply here and ^^^ only prepare reply
if
err
!=
nil
{
return
err
return
nil
,
err
}
req
.
Close
()
// XXX err?
}
}
}
// m1serve drives storage by master messages during service phase.
// m1serve drives storage by master messages during service phase.
...
@@ -324,6 +335,7 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
...
@@ -324,6 +335,7 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
// reply M we are ready
// reply M we are ready
// XXX according to current neo/py this is separate send - not reply - and so we do here
// XXX according to current neo/py this is separate send - not reply - and so we do here
err
=
reqStart
.
Reply
(
&
neo
.
NotifyReady
{})
err
=
reqStart
.
Reply
(
&
neo
.
NotifyReady
{})
reqStart
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -334,9 +346,16 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
...
@@ -334,9 +346,16 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
stor
.
m1serve1
(
ctx
,
req
)
req
.
Close
()
if
err
!=
nil
{
return
err
}
}
}
req
.
Close
()
// XXX stub, err
// m1serve1 handles one message from master under m1serve
func
(
stor
*
Storage
)
m1serve1
(
ctx
context
.
Context
,
req
neo
.
Request
)
error
{
switch
msg
:=
req
.
Msg
.
(
type
)
{
switch
msg
:=
req
.
Msg
.
(
type
)
{
default
:
default
:
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
return
fmt
.
Errorf
(
"unexpected message: %T"
,
msg
)
...
@@ -355,7 +374,8 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
...
@@ -355,7 +374,8 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
// TODO commit related messages
// TODO commit related messages
}
}
}
return
nil
}
}
// --- serve incoming connections from other nodes ---
// --- serve incoming connections from other nodes ---
...
@@ -466,6 +486,7 @@ func (stor *Storage) serveClient(ctx context.Context, req neo.Request) {
...
@@ -466,6 +486,7 @@ func (stor *Storage) serveClient(ctx context.Context, req neo.Request) {
for
{
for
{
resp
:=
stor
.
serveClient1
(
ctx
,
req
.
Msg
)
resp
:=
stor
.
serveClient1
(
ctx
,
req
.
Msg
)
err
:=
req
.
Reply
(
resp
)
err
:=
req
.
Reply
(
resp
)
req
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
ctx
,
err
)
log
.
Error
(
ctx
,
err
)
return
return
...
...
Kirill Smelkov
@kirr
mentioned in commit
ec4b3ce0
·
Jul 12, 2018
mentioned in commit
ec4b3ce0
mentioned in commit ec4b3ce09d46f046e1487e9f25c689ee8a7fc09a
Toggle commit list
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