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
87a6b2d4
Commit
87a6b2d4
authored
Aug 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
70c2e81a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
21 deletions
+22
-21
go/neo/connection.go
go/neo/connection.go
+18
-21
go/neo/neotools/storage.go
go/neo/neotools/storage.go
+4
-0
No files found.
go/neo/connection.go
View file @
87a6b2d4
...
...
@@ -98,8 +98,10 @@ type Conn struct {
rxdownOnce
sync
.
Once
// ----//----
rxerrOnce
sync
.
Once
// rx error is reported only once - then it is link down or closed
closed
int32
// 1 if Close was called or "connection closed" entry
// incremented during every replyNoConn() in progress
rxclosed
int32
// whether CloseRecv was called
txclosed
int32
// whether CloseSend was called
// closed int32 // 1 if Close was called or "connection closed" entry
// // incremented during every replyNoConn() in progress
errMsg
*
Error
// error message for replyNoConn
}
...
...
@@ -314,25 +316,23 @@ func (c *Conn) shutdownRX(errMsg *Error) {
}
// time to keep record of a closed connection so that we can properly reply
// "connection closed" if a packet comes in with this connection's connID.
var
connKeepClosed
=
1
*
time
.
Minute
// CloseRecv closes reading end of connection.
//
// A peer will receive "connection closed" if it tries to send to connection
// with closed reading end.
//
// XXX no race wrt in-progress c.rxq <- ... ?
//
// Any blocked Recv*() will be unblocked and return error.
// The peer will receive "connection closed" if it tries to send anything after.
//
// It is safe to call CloseRecv several times.
func
(
c
*
Conn
)
CloseRecv
()
{
// XXX c.closedRecv = 1?
c
.
shutdownRX
(
errConnClosed
)
// XXX ok?
atomic
.
StoreInt32
(
&
c
.
rxclosed
,
1
)
c
.
shutdownRX
(
errConnClosed
)
// deque
all pakc
ets already queued in c.rxq
// deque
ue all pack
ets already queued in c.rxq
// (once serveRecv sees c.rxdown it won't try to put new packets into
// c.rxq but something finite could be already there)
// c.rxq
,
but something finite could be already there)
i
:=
0
loop
:
for
{
...
...
@@ -392,7 +392,8 @@ func (c *Conn) Close() error {
}
nl
.
connMu
.
Unlock
()
atomic
.
StoreInt32
(
&
c
.
closed
,
1
)
atomic
.
StoreInt32
(
&
c
.
rxclosed
,
1
)
atomic
.
StoreInt32
(
&
c
.
txclosed
,
1
)
c
.
shutdown
()
return
nil
}
...
...
@@ -437,13 +438,9 @@ func (nl *NodeLink) Accept(/*ctx context.Context*/) (c *Conn, err error) {
// errRecvShutdown returns appropriate error when c.rxdown is found ready in recvPkt
func
(
c
*
Conn
)
errRecvShutdown
()
error
{
switch
{
// XXX adjust for CloseRead (shutdownRX)
case
atomic
.
LoadInt32
(
&
c
.
closed
)
!=
0
:
case
atomic
.
LoadInt32
(
&
c
.
rxclosed
)
!=
0
:
return
ErrClosedConn
case
c
.
errMsg
!=
nil
:
return
ErrClosedConn
// shutdownRX
case
atomic
.
LoadUint32
(
&
c
.
nodeLink
.
closed
)
!=
0
:
return
ErrLinkClosed
...
...
@@ -544,7 +541,7 @@ func (nl *NodeLink) serveRecv() {
// don't even try to `conn.rxq <- ...` if .rxdown is ready
// ( else since select is picking random ready variant Recv/serveRecv
// could receve something on rxdown Conn half sometimes )
// could rece
i
ve something on rxdown Conn half sometimes )
rxdown
:=
false
select
{
case
<-
conn
.
rxdown
:
...
...
@@ -630,7 +627,7 @@ type txReq struct {
// errSendShutdown returns appropriate error when c.txdown is found ready in Send
func
(
c
*
Conn
)
errSendShutdown
()
error
{
switch
{
case
atomic
.
LoadInt32
(
&
c
.
closed
)
!=
0
:
case
atomic
.
LoadInt32
(
&
c
.
tx
closed
)
!=
0
:
return
ErrClosedConn
// the only other error possible besides Conn being .Close()'ed is that
...
...
@@ -1244,7 +1241,7 @@ func (link *NodeLink) Recv1() (Request, error) {
// noone will be reading from conn anymore - shutdown rx so that if
// peer sends any another packet with same .ConnID serveRecv does not
// deadlock trying to put it to conn.rxq.
conn
.
CloseRe
ad
()
conn
.
CloseRe
cv
()
return
Request
{
Msg
:
msg
,
conn
:
conn
},
nil
}
...
...
@@ -1276,7 +1273,7 @@ func (link *NodeLink) Send1(msg Msg) error {
return
err
}
// XXX conn.CloseRe
ad
() ?
// XXX conn.CloseRe
cv
() ?
err1
:=
conn
.
Send
(
msg
)
err2
:=
conn
.
Close
()
...
...
go/neo/neotools/storage.go
View file @
87a6b2d4
...
...
@@ -45,6 +45,10 @@ Run NEO storage node.
// FIXME use w (see flags.SetOutput)
}
// TODO set GOMAXPROCS *= N (a lot of file IO) + link
// https://groups.google.com/forum/#!msg/golang-nuts/jPb_h3TvlKE/rQwbg-etCAAJ
// https://github.com/golang/go/issues/6817
func
storageMain
(
argv
[]
string
)
{
flags
:=
flag
.
NewFlagSet
(
""
,
flag
.
ExitOnError
)
flags
.
Usage
=
func
()
{
storageUsage
(
os
.
Stderr
);
flags
.
PrintDefaults
()
}
// XXX prettify
...
...
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