Skip to content

Commit

Permalink
new dir koala
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjing committed Jan 4, 2021
1 parent 5cdbf44 commit dc3ece2
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
example/example
example/example.test
example/nohup.out
example/recorder/recorder
example/replayer/replayer
example/replayer/replayer.test
example/replayer/example.test
Expand Down
2 changes: 1 addition & 1 deletion plugins/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package plugins
import (
"context"

"github.com/didi/sharingan/recorder/recording"
"github.com/didi/sharingan/recorder/koala/recording"
)

var recorders []recording.Recorder
Expand Down
2 changes: 1 addition & 1 deletion plugins/recorder_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/didi/sharingan/recorder"
"github.com/didi/sharingan/recorder/recording"
"github.com/didi/sharingan/recorder/koala/recording"
"github.com/didi/sharingan/recorder/utils"

"github.com/v2pro/plz/countlog"
Expand Down
23 changes: 11 additions & 12 deletions recorder/hook/hook.go → recorder/koala/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"net"
"syscall"

"github.com/didi/sharingan/recorder/internal"
"github.com/didi/sharingan/recorder/sut"
"github.com/didi/sharingan/recorder/koala/sut"

"github.com/v2pro/plz/countlog"
)
Expand All @@ -23,8 +22,8 @@ func Start() {
}

func setupAcceptHook() {
internal.RegisterOnAccept(func(serverSocketFD int, clientSocketFD int, sa syscall.Sockaddr) {
gid := sut.ThreadID(internal.GetCurrentGoRoutineID())
RegisterOnAccept(func(serverSocketFD int, clientSocketFD int, sa syscall.Sockaddr) {
gid := sut.ThreadID(GetCurrentGoRoutineID())

origAddr := sockaddrToTCP(sa)

Expand All @@ -43,8 +42,8 @@ func setupAcceptHook() {
}

func setupConnectHook() {
internal.RegisterOnConnect(func(fd int, sa syscall.Sockaddr) {
gid := sut.ThreadID(internal.GetCurrentGoRoutineID())
RegisterOnConnect(func(fd int, sa syscall.Sockaddr) {
gid := sut.ThreadID(GetCurrentGoRoutineID())

ipv4Addr, _ := sa.(*syscall.SockaddrInet4)
if ipv4Addr == nil {
Expand Down Expand Up @@ -73,8 +72,8 @@ func setupConnectHook() {
}

func setupSendHook() {
internal.RegisterOnSend(func(fd int, network string, raddr net.Addr, span []byte) {
gid := sut.ThreadID(internal.GetCurrentGoRoutineID())
RegisterOnSend(func(fd int, network string, raddr net.Addr, span []byte) {
gid := sut.ThreadID(GetCurrentGoRoutineID())
if gid == ignoreThreadID {
return
}
Expand All @@ -94,8 +93,8 @@ func setupSendHook() {
}

func setupRecvHook() {
internal.RegisterOnRecv(func(fd int, network string, raddr net.Addr, span []byte) {
gid := sut.ThreadID(internal.GetCurrentGoRoutineID())
RegisterOnRecv(func(fd int, network string, raddr net.Addr, span []byte) {
gid := sut.ThreadID(GetCurrentGoRoutineID())
if gid == ignoreThreadID {
return
}
Expand All @@ -111,15 +110,15 @@ func setupRecvHook() {
}

func setupCloseHook() {
internal.RegisterOnClose(func(fd int) {
RegisterOnClose(func(fd int) {
countlog.Debug("event!sut.close", "socketFD", fd)
sut.RemoveGlobalSock(sut.SocketFD(fd))
})
}

func setupGoRoutineExitHook() {
// true goroutineID
internal.RegisterOnGoRoutineExit(func(gid int64) {
RegisterOnGoRoutineExit(func(gid int64) {
countlog.Debug("event!sut.goroutine_exit", "threadID", gid)
sut.OperateThreadOnRecordingSession(sut.ThreadID(gid), func(thread *sut.Thread) {
thread.OnShutdown()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build recorder

package internal
package hook

import (
"net"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build !recorder

package internal
package hook

import (
"net"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion recorder/sut/thread.go → recorder/koala/sut/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"
"unsafe"

"github.com/didi/sharingan/recorder/recording"
"github.com/didi/sharingan/recorder/koala/recording"

"github.com/v2pro/plz/countlog"
)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions recorder/recorder.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package recorder

import (
"github.com/didi/sharingan/recorder/internal"
"github.com/didi/sharingan/recorder/koala/hook"
)

// GetCurrentGoRoutineID get current goRoutineID incase with delegatedID
func GetCurrentGoRoutineID() int64 {
return internal.GetCurrentGoRoutineID()
return hook.GetCurrentGoRoutineID()
}

// SetDelegatedFromGoRoutineID set goRoutine delegatedID
func SetDelegatedFromGoRoutineID(gID int64) {
internal.SetDelegatedFromGoRoutineID(gID)
hook.SetDelegatedFromGoRoutineID(gID)
}
6 changes: 3 additions & 3 deletions tag_with_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

"github.com/didi/sharingan/plugins"
"github.com/didi/sharingan/recorder"
"github.com/didi/sharingan/recorder/hook"
"github.com/didi/sharingan/recorder/logger"
"github.com/didi/sharingan/recorder/sut"
"github.com/didi/sharingan/recorder/koala/hook"
"github.com/didi/sharingan/recorder/koala/logger"
"github.com/didi/sharingan/recorder/koala/sut"
)

// GetCurrentGoRoutineID get current goroutineID incase SetDelegatedFromGoRoutineID
Expand Down

0 comments on commit dc3ece2

Please sign in to comment.