Skip to content

Commit

Permalink
重构mysql组件
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Sep 19, 2023
1 parent 64f07f2 commit bd92db9
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 218 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,16 @@ cd bin

# 依赖
- lua
- bson
- mongo
- lbson
- luabt
- lhttp
- lcurl
- ljson
- luabus
- lcrypt
- lcjson
- lstdfs
- luakit
- lualog
- lbuffer
- lcodec
- luaxlsx
- lua-protobuf

Expand Down
6 changes: 3 additions & 3 deletions bin/database.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ set_env("QUANTA_REDIS_URLS", [[
redis://root:[email protected]:6379;
]])
--mysql
--set_env("QUANTA_MYSQL_URLS", [[
-- mysql://root:[email protected]:6379/quanta;
--]])
set_env("QUANTA_MYSQL_URLS", [[
mysql://root:[email protected]:3306/quanta;
]])
4 changes: 2 additions & 2 deletions core/luabus/src/lua_socket_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int lua_socket_mgr::listen(lua_State* L, const char* ip, int port) {
}

eproto_type proto_type = (eproto_type)luaL_optinteger(L, 3, (int)eproto_type::proto_rpc);
auto listener = new lua_socket_node(token, m_lvm, m_mgr, m_router, proto_type);
auto listener = new lua_socket_node(token, L, m_mgr, m_router, proto_type);
if (proto_type == eproto_type::proto_rpc) {
listener->create_codec();
}
Expand All @@ -38,7 +38,7 @@ int lua_socket_mgr::connect(lua_State* L, const char* ip, const char* port, int
}

eproto_type proto_type = (eproto_type)luaL_optinteger(L, 4, (int)eproto_type::proto_rpc);
auto socket_node = new lua_socket_node(token, m_lvm, m_mgr, m_router, proto_type);
auto socket_node = new lua_socket_node(token, L, m_mgr, m_router, proto_type);
if (proto_type == eproto_type::proto_rpc) {
socket_node->create_codec();
}
Expand Down
7 changes: 5 additions & 2 deletions core/luabus/src/socket_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void socket_stream::close() {
return;
}
if (m_codec) {
m_codec->clean();
m_codec = nullptr;
}
shutdown(m_socket, SD_RECEIVE);
Expand Down Expand Up @@ -463,6 +462,10 @@ void socket_stream::do_recv(size_t max_len, bool is_eof)
void socket_stream::dispatch_package() {
int64_t now = ltimer::steady_ms();
while (m_link_status == elink_status::link_connected) {
if (!m_codec){
on_error("codec-is-bnull");
break;
}
size_t data_len;
auto* data = m_recv_buffer->data(&data_len);
if (data_len == 0) break;
Expand All @@ -482,7 +485,7 @@ void socket_stream::dispatch_package() {
m_package_cb(slice);
if (!m_codec) break;
// 数据包解析失败
if (!m_codec || m_codec->failed()) {
if (m_codec->failed()) {
on_error(m_codec->err());
break;
}
Expand Down
Loading

0 comments on commit bd92db9

Please sign in to comment.