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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
8dbd955e
Commit
8dbd955e
authored
Jun 16, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X API for tracepoints is more or less ready
parent
55cea17a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
13 deletions
+65
-13
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+9
-2
go/neo/server/trace.go
go/neo/server/trace.go
+4
-2
go/neo/trace.go
go/neo/trace.go
+3
-2
go/xcommon/tracing/tracing.go
go/xcommon/tracing/tracing.go
+49
-7
No files found.
go/neo/server/cluster_test.go
View file @
8dbd955e
...
...
@@ -31,6 +31,7 @@ import (
//"../../zodb"
"../../zodb/storage/fs1"
"../../xcommon/tracing"
"../../xcommon/xnet"
"../../xcommon/xnet/pipenet"
"../../xcommon/xsync"
...
...
@@ -128,17 +129,23 @@ func TestMasterStorage(t *testing.T) {
net
:=
pipenet
.
New
(
"testnet"
)
// test network
tg
:=
&
tracing
.
Group
{}
defer
tg
.
Done
()
tracing
.
Lock
()
neo_traceConnRecv_Attach
(
tracer
.
traceNeoConnRecv
)
neo_traceConnSend_Attach
(
tracer
.
traceNeoConnSend
)
neo_traceConnRecv_Attach
(
t
g
,
t
racer
.
traceNeoConnRecv
)
neo_traceConnSend_Attach
(
t
g
,
t
racer
.
traceNeoConnSend
)
tracing
.
Unlock
()
/*
defer func() {
tracing.Lock()
defer tracing.Unlock()
tctx.Done()
}()
*/
// shortcut for addresses
xaddr
:=
func
(
addr
string
)
*
pipenet
.
Addr
{
...
...
go/neo/server/trace.go
View file @
8dbd955e
...
...
@@ -20,6 +20,8 @@ package server
import
(
"../../neo"
"../../xcommon/tracing"
_
"unsafe"
)
...
...
@@ -27,7 +29,7 @@ import (
// + check consistency (e.g. by hash in neo.trace and here must be the same)
//go:linkname neo_traceConnRecv_Attach _/home/kirr/src/wendelin/neo/neoppod-t/go/neo.traceConnRecv_Attach
func
neo_traceConnRecv_Attach
(
func
(
*
neo
.
Conn
,
neo
.
Msg
))
func
neo_traceConnRecv_Attach
(
*
tracing
.
Group
,
func
(
*
neo
.
Conn
,
neo
.
Msg
))
*
tracing
.
Probe
//go:linkname neo_traceConnSend_Attach _/home/kirr/src/wendelin/neo/neoppod-t/go/neo.traceConnSend_Attach
func
neo_traceConnSend_Attach
(
func
(
*
neo
.
Conn
,
neo
.
Msg
))
func
neo_traceConnSend_Attach
(
*
tracing
.
Group
,
func
(
*
neo
.
Conn
,
neo
.
Msg
))
*
tracing
.
Probe
go/neo/trace.go
View file @
8dbd955e
...
...
@@ -69,14 +69,15 @@ func traceConnSend(c *Conn, msg Msg) {
_traceConnSend_runprobev
(
c
,
msg
)
}
}
func
_traceConnSend_runprobev
(
c
*
Conn
,
msg
Msg
)
{
for
p
:=
_traceConnSend
;
p
!=
nil
;
p
=
(
*
_t_traceConnSend
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
c
,
msg
)
}
}
func
traceConnSend_Attach
(
probe
func
(
*
Conn
,
Msg
))
*
tracing
.
Probe
{
func
traceConnSend_Attach
(
tg
*
tracing
.
Group
,
probe
func
(
*
Conn
,
Msg
))
*
tracing
.
Probe
{
p
:=
_t_traceConnSend
{
probefunc
:
probe
}
tracing
.
AttachProbe
((
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceConnSend
)),
&
p
.
Probe
)
tracing
.
AttachProbe
(
tg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceConnSend
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
go/xcommon/tracing/tracing.go
View file @
8dbd955e
...
...
@@ -65,29 +65,44 @@ func verifyLocked() {
}
}
// verifyUnlocked makes sure tracing is not locked and panics otherwise
func
verifyUnlocked
()
{
if
atomic
.
LoadInt32
(
&
traceLocked
)
!=
0
{
panic
(
"tracing must be unlocked"
)
}
}
// Probe describes one probe attached to a tracepoint
XXX
// Probe describes one probe attached to a tracepoint
type
Probe
struct
{
prev
,
next
*
Probe
// probefunc interface{} // func(some arguments)
// implicitly:
// probefunc func(some arguments)
}
// Next return next probe attached to the same tracepoint
// It is safe to iterate Next under any conditions.
func
(
p
*
Probe
)
Next
()
*
Probe
{
return
p
.
next
}
// AttachProbe attaches Probe to the end of a probe list
// Must be called under Lock
func
AttachProbe
(
listp
**
Probe
,
probe
*
Probe
)
{
// AttachProbe attaches newly created Probe to the end of a probe list
// If group is non-nil the probe is also added to the group.
// Must be called under Lock.
// Probe must be newly created.
func
AttachProbe
(
g
*
Group
,
listp
**
Probe
,
probe
*
Probe
)
{
verifyLocked
()
if
!
(
probe
.
prev
==
nil
||
probe
.
next
==
nil
)
{
panic
(
"attach probe: probe is not newly created"
)
}
var
last
*
Probe
for
p
:=
*
listp
;
p
!=
nil
;
p
=
p
.
next
{
last
=
p
}
// p := &Probe{prev: last, next: nil, probefunc: probefunc}
if
last
!=
nil
{
last
.
next
=
probe
probe
.
prev
=
last
...
...
@@ -95,7 +110,9 @@ func AttachProbe(listp **Probe, probe *Probe) {
*
listp
=
probe
}
// return p
if
g
!=
nil
{
g
.
Add
(
probe
)
}
}
// Detach detaches probe from a tracepoint
...
...
@@ -127,3 +144,28 @@ func (p *Probe) Detach() {
// time it does not do harm
p
.
prev
=
p
}
// Group is a group of probes attached to tracepoints
type
Group
struct
{
probev
[]
*
Probe
}
// Add adds a probe to the group
// Must be called under Lock
func
(
g
*
Group
)
Add
(
p
*
Probe
)
{
verifyLocked
()
g
.
probev
=
append
(
g
.
probev
)
}
// Done detaches all probes registered in the group
// Must be called under normal conditions, not under Lock
func
(
g
*
Group
)
Done
()
{
verifyUnlocked
()
Lock
()
defer
Unlock
()
for
_
,
p
:=
range
g
.
probev
{
p
.
Detach
()
}
g
.
probev
=
nil
}
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