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
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
Stefane Fermigier
neo
Commits
8cb4e9c0
Commit
8cb4e9c0
authored
Apr 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
badeb060
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
go/neo/connection.go
go/neo/connection.go
+15
-2
go/neo/storage.go
go/neo/storage.go
+8
-11
No files found.
go/neo/connection.go
View file @
8cb4e9c0
...
...
@@ -464,10 +464,12 @@ func (nl *NodeLink) serveSend() {
// ---- raw IO ----
const
dumpio
=
true
// sendPkt sends raw packet to peer
// tx error, if any, is returned as is and is analyzed in serveSend
func
(
nl
*
NodeLink
)
sendPkt
(
pkt
*
PktBuf
)
error
{
if
true
{
if
dumpio
{
// XXX -> log
fmt
.
Printf
(
"%v > %v: %v
\n
"
,
nl
.
peerLink
.
LocalAddr
(),
nl
.
peerLink
.
RemoteAddr
(),
pkt
)
//defer fmt.Printf("\t-> sendPkt err: %v\n", err)
...
...
@@ -524,7 +526,7 @@ func (nl *NodeLink) recvPkt() (*PktBuf, error) {
}
}
if
true
{
if
dumpio
{
// XXX -> log
fmt
.
Printf
(
"%v < %v: %v
\n
"
,
nl
.
peerLink
.
LocalAddr
(),
nl
.
peerLink
.
RemoteAddr
(),
pkt
)
}
...
...
@@ -572,6 +574,17 @@ func Listen(network, laddr string) (*Listener, error) {
// ---- for convenience: String ----
func
(
nl
*
NodeLink
)
String
()
string
{
s
:=
fmt
.
Sprintf
(
"%s - %s"
,
nl
.
peerLink
.
LocalAddr
(),
nl
.
peerLink
.
RemoteAddr
())
return
s
// XXX add "(closed)" if nl is closed ?
}
func
(
c
*
Conn
)
String
()
string
{
s
:=
fmt
.
Sprintf
(
"%s .%d"
,
c
.
nodeLink
,
c
.
connId
)
return
s
// XXX add "(closed)" if c is closed ?
}
// ----------------------------------------
...
...
go/neo/storage.go
View file @
8cb4e9c0
...
...
@@ -44,7 +44,7 @@ func NewStorage(zstor zodb.IStorage) *Storage {
// ServeLink serves incoming node-node link connection
func
(
stor
*
Storage
)
ServeLink
(
ctx
context
.
Context
,
link
*
NodeLink
)
{
fmt
.
Printf
(
"stor:
serving new node %s <-> %s
\n
"
,
link
.
peerLink
.
LocalAddr
(),
link
.
peerLink
.
RemoteAddr
()
)
fmt
.
Printf
(
"stor:
%s: serving new node
\n
"
,
link
)
// close link when either cancelling or returning (e.g. due to an error)
// ( when cancelling - link.Close will signal to all current IO to
...
...
@@ -58,12 +58,13 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
// XXX tell peers we are shutting down?
case
<-
retch
:
}
fmt
.
Printf
(
"stor:
closing link to %s
\n
"
,
link
.
peerLink
.
RemoteAddr
()
)
fmt
.
Printf
(
"stor:
%v: closing link
\n
"
,
link
)
link
.
Close
()
// XXX err
}()
nodeInfo
,
err
:=
IdentifyPeer
(
link
,
STORAGE
)
if
err
!=
nil
{
// XXX include link here or in IdentifyPeer ?
fmt
.
Printf
(
"peer identification failed: %v
\n
"
,
err
)
return
}
...
...
@@ -74,7 +75,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
serveConn
=
stor
.
ServeClient
default
:
fmt
.
Printf
(
"
unexpected peer type: %v
\n
"
,
nodeInfo
.
NodeType
)
fmt
.
Printf
(
"
stor: %v: unexpected peer type: %v
\n
"
,
link
,
nodeInfo
.
NodeType
)
return
}
...
...
@@ -82,7 +83,8 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
for
{
conn
,
err
:=
link
.
Accept
()
if
err
!=
nil
{
fmt
.
Printf
(
"accept: %v
\n
"
,
err
)
// XXX err ctx
// XXX both link and accept op should be generated in link.Accept
fmt
.
Printf
(
"stor: %v: accept: %v
\n
"
,
link
,
err
)
// XXX err ctx
break
}
...
...
@@ -94,14 +96,9 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
// TODO wait all spawned serveConn
}
// connAddr returns string describing conn XXX text, naming
func
connAddr
(
conn
*
Conn
)
string
{
return
fmt
.
Sprintf
(
"%s .%d"
,
conn
.
nodeLink
.
peerLink
.
RemoteAddr
(),
conn
.
connId
)
}
// ServeClient serves incoming connection on which peer identified itself as client
func
(
stor
*
Storage
)
ServeClient
(
ctx
context
.
Context
,
conn
*
Conn
)
{
fmt
.
Printf
(
"stor:
serving new client conn %s
\n
"
,
connAddr
(
conn
)
)
fmt
.
Printf
(
"stor:
%s: serving new client conn
\n
"
,
conn
)
// close connection when either cancelling or returning (e.g. due to an error)
// ( when cancelling - conn.Close will signal to current IO to
...
...
@@ -115,7 +112,7 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *Conn) {
// XXX tell client we are shutting down?
case
<-
retch
:
}
fmt
.
Printf
(
"stor:
closing client conn %s
\n
"
,
connAddr
(
conn
)
)
fmt
.
Printf
(
"stor:
%v: closing client conn
\n
"
,
conn
)
conn
.
Close
()
// XXX 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