Giter Site home page Giter Site logo

cherry-game / cherry Goto Github PK

View Code? Open in Web Editor NEW
316.0 7.0 52.0 8.55 MB

Actor model game server framework based on golang

Home Page: https://cherry-game.github.io

License: MIT License

Go 99.40% Batchfile 0.01% Makefile 0.21% Shell 0.38%
golang game gameserver game-engine pitaya gamedev http websocket nats-server natsio

cherry's People

Contributors

goldpasser avatar hollowj avatar phantacix avatar qq358860528 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cherry's Issues

跑demo_chat发现一个竞争点

WARNING: DATA RACE
Write at 0x00c0001ce828 by goroutine 44:
sync/atomic.StoreInt64()
C:/Program Files/Go/src/runtime/race_amd64.s:237 +0xb
sync/atomic.StoreInt64()
:1 +0x15
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).processPacket()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:266 +0x2b0
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).readChan()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:166 +0x116
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).Run.func2()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:140 +0x33

Previous read at 0x00c0001ce828 by goroutine 43:
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).writeChan()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:192 +0x3a5
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).Run.func1()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:139 +0x33

Goroutine 44 (running) created at:
github.com/cherry-game/cherry/net/parser/pomelo.(*Agent).Run()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/agent.go:140 +0xfc
github.com/cherry-game/cherry/net/parser/pomelo.(*actor).defaultOnConnectFunc()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/parser/pomelo/actor.go:91 +0x446
github.com/cherry-game/cherry/net/parser/pomelo.(*actor).defaultOnConnectFunc-fm()
:1 +0x47
github.com/cherry-game/cherry/net/connector.(*Connector).Start.func1()
D:/Workspace/gopath/pkg/mod/github.com/cherry-game/[email protected]/net/connector/connector.go:45 +0x93

net/parser/pomelo/agent.go:192
a.lastAt没有用atomic.LoadInt64来读取

点个赞

pitaya之前看过,有点臃肿,nanoserver又略显简陋,cherry实现的就比较合适,会长期关注,谢谢作者的付出。

使用pomeloClient的websocket做压力测试,发现github.com\gorilla\websocket会报concurrent write to websocket connection

报错日志如下:
18:19:01.519 bot ERROR actor/actor_timer.go:142 concurrent write to websocket connection
github.com/cherry-game/cherry/net/actor.(*actorTimer).updateTimer.func2
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor_timer.go:142
github.com/cherry-game/cherry/extend/utils.catchError
D:/Workspace/go-game/cherry_server_dev/cherry/extend/utils/utils.go:19
runtime.gopanic
C:/Program Files/Go/src/runtime/panic.go:914
github.com/gorilla/websocket.(*messageWriter).flushFrame
D:/Workspace/gopath/pkg/mod/github.com/gorilla/[email protected]/conn.go:617
github.com/gorilla/websocket.(*messageWriter).Close
D:/Workspace/gopath/pkg/mod/github.com/gorilla/[email protected]/conn.go:731
github.com/gorilla/websocket.(*Conn).beginMessage
D:/Workspace/gopath/pkg/mod/github.com/gorilla/[email protected]/conn.go:480
github.com/gorilla/websocket.(*Conn).NextWriter
D:/Workspace/gopath/pkg/mod/github.com/gorilla/[email protected]/conn.go:520
github.com/gorilla/websocket.(*Conn).WriteMessage
D:/Workspace/gopath/pkg/mod/github.com/gorilla/[email protected]/conn.go:773
github.com/cherry-game/cherry/net/connector.(*WSConn).Write
D:/Workspace/go-game/cherry_server_dev/cherry/net/connector/ws_connector.go:141
github.com/cherry-game/cherry/net/parser/pomelo/client.(*Client).Send
D:/Workspace/go-game/cherry_server_dev/cherry/net/parser/pomelo/client/client.go:379
github.com/cherry-game/cherry/net/parser/pomelo/client.(*Client).Request
D:/Workspace/go-game/cherry_server_dev/cherry/net/parser/pomelo/client/client.go:138
main.(*bot).doubleBet
D:/Workspace/go-game/cherry_server_dev/bot/double.go:88
main.(*bot).subscribeDouble.func1.2
D:/Workspace/go-game/cherry_server_dev/bot/double.go:36
github.com/cherry-game/cherry/net/actor.(*actorTimer).updateTimer.func1
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor_timer.go:140
github.com/cherry-game/cherry/extend/utils.Try.func1
D:/Workspace/go-game/cherry_server_dev/cherry/extend/utils/utils.go:11
github.com/cherry-game/cherry/extend/utils.Try
D:/Workspace/go-game/cherry_server_dev/cherry/extend/utils/utils.go:13
github.com/cherry-game/cherry/net/actor.(*actorTimer).updateTimer
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor_timer.go:139
reflect.Value.call
C:/Program Files/Go/src/reflect/value.go:596
reflect.Value.Call
C:/Program Files/Go/src/reflect/value.go:380
github.com/cherry-game/cherry/net/actor.InvokeRemoteFunc.func3
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/invoke.go:63
github.com/cherry-game/cherry/extend/utils.Try.func1
D:/Workspace/go-game/cherry_server_dev/cherry/extend/utils/utils.go:11
github.com/cherry-game/cherry/extend/utils.Try
D:/Workspace/go-game/cherry_server_dev/cherry/extend/utils/utils.go:13
github.com/cherry-game/cherry/net/actor.InvokeRemoteFunc
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/invoke.go:61
github.com/cherry-game/cherry/net/actor.(*Actor).invokeFunc
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor.go:224
github.com/cherry-game/cherry/net/actor.(*Actor).processRemote
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor.go:158
github.com/cherry-game/cherry/net/actor.(*Actor).loop
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor.go:83
github.com/cherry-game/cherry/net/actor.(*Actor).run
D:/Workspace/go-game/cherry_server_dev/cherry/net/actor/actor.go:61

demo_game_cluster中gate踢下线的问题

在测试gate的websocket连接的时候发现一个踢下线的问题。

问题:同一个用户请求两次路由gate.user.login后,再通过这个函数 agent, ok := pomelo.GetAgentWithUID(userId),无法获取到agent。

场景:已登录建立了websocket连接的用户,再请求这个路由gate.user.login建立新的websocket连接

原因:再次登录时会将之前的agent踢下线(会解绑用户),再重新绑定用户uid。但是踢下线操作比较费时,导致在完成了用户绑定后,又进行了解绑,使得uidMap中的uid被删除了。

规避:
image

run test_sample1 error when client demo open

18:25:05.703 DEBUG [node#gate-1] test-cherry/cherry.go:120 [uid = 0] session create. [nodeId = gate-1, sid = 8e53813d-35e5-4385-ab96-d4f4c8ec84d3, address = 127.0.0.1]
18:25:05.705 DEBUG [node#gate-1] command/handshake.go:52 [uid = 0] request handshake. [data = map[code:200 routes:map[] sys:map[heartbeat:60]]]
18:25:05.705 DEBUG [node#gate-1] command/handshake_ack.go:22 [uid = 0] request handshakeACK.
18:25:05.705 DEBUG [node#gate-1] handler/component.go:232 [uid = 0] [local handler] [route = gate.userHandler.login], [group-index = 0]
18:25:05.705 WARN [node#gate-1] handler/handler_group.go:120 recover in executor. goroutine 26 [running]:
runtime/debug.Stack()
D:/Software/Dev/go/src/runtime/debug/stack.go:24 +0x65
github.com/cherry-game/cherry/net/handler.(*HandlerGroup).invokeExecutor.func1()
E:/go_workspace/test-cherry/net/handler/handler_group.go:120 +0x53
panic({0x13bff40, 0xc000380040})
D:/Software/Dev/go/src/runtime/panic.go:1038 +0x215
reflect.Value.call({0x13eb300, 0xc0000932b0, 0x1d476080a28}, {0x14e03c5, 0x4}, {0xc00039a000, 0x3, 0x0})
D:/Software/Dev/go/src/reflect/value.go:411 +0x19ff
reflect.Value.Call({0x13eb300, 0xc0000932b0, 0xc0002dbbc0}, {0xc00039a000, 0x3, 0x3})
D:/Software/Dev/go/src/reflect/value.go:339 +0xc5
github.com/cherry-game/cherry/net/handler.(*ExecutorLocal).Invoke(0xc000450310)
E:/go_workspace/test-cherry/net/handler/executor_local.go:71 +0x954
github.com/cherry-game/cherry/net/handler.(*HandlerGroup).invokeExecutor(0x0, {0x15d97f8, 0xc000450310})
E:/go_workspace/test-cherry/net/handler/handler_group.go:125 +0x70
github.com/cherry-game/cherry/net/handler.(*HandlerGroup).run.func1(0xc000092060)
E:/go_workspace/test-cherry/net/handler/handler_group.go:109 +0x4d
created by github.com/cherry-game/cherry/net/handler.(*HandlerGroup).run
E:/go_workspace/test-cherry/net/handler/handler_group.go:104 +0x1bb

18:25:05.706 WARN [node#gate-1] handler/handler_group.go:121 executor fail [gate.userHandler.login]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.