Skip to content

Commit

Permalink
优化代码删除未引用文件
Browse files Browse the repository at this point in the history
  • Loading branch information
hero1s committed May 25, 2024
1 parent 4e27f2d commit 2dd5338
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 149 deletions.
2 changes: 1 addition & 1 deletion core/luabus/src/socket_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void socket_stream::dispatch_package(bool reset) {
}
// 数据包解析失败
if (m_codec->failed()) {
on_error(m_codec->err());
on_error(fmt::format("codec decode failed:{}", m_codec->err()).c_str());
return;
}
size_t read_size = m_codec->get_packet_len();
Expand Down
1 change: 0 additions & 1 deletion core/plugins/lplugins.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<ClInclude Include="src\lcodec\lcodec.h"/>
<ClInclude Include="src\lcodec\mysql.h"/>
<ClInclude Include="src\lcodec\redis.h"/>
<ClInclude Include="src\lcodec\url.h"/>
<ClInclude Include="src\lcodec\utf8.h"/>
<ClInclude Include="src\lcodec\websocket.h"/>
<ClInclude Include="src\lcrypt\base64.h"/>
Expand Down
3 changes: 0 additions & 3 deletions core/plugins/lplugins.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
<ClInclude Include="src\lcodec\redis.h">
<Filter>lcodec</Filter>
</ClInclude>
<ClInclude Include="src\lcodec\url.h">
<Filter>lcodec</Filter>
</ClInclude>
<ClInclude Include="src\lcodec\utf8.h">
<Filter>lcodec</Filter>
</ClInclude>
Expand Down
71 changes: 37 additions & 34 deletions core/plugins/src/lbson/bson.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ namespace lbson {
}

int date(lua_State* L, int64_t value) {
return make_bson_value(L, bson_type::BSON_DATE, (const char *)&value, sizeof(value));
return make_bson_value(L, bson_type::BSON_DATE, (uint8_t*)&value, sizeof(value));
}

int int64(lua_State* L, int64_t value) {
return make_bson_value(L, bson_type::BSON_INT64, (const char *)&value, sizeof(value));
return make_bson_value(L, bson_type::BSON_INT64, (uint8_t*)&value, sizeof(value));
}

int objectid(lua_State* L) {
Expand All @@ -126,52 +126,54 @@ namespace lbson {
if (data_len != 24) return luaL_error(L, "Invalid object id");
char buffer[16] = { 0 };
write_objectid(L, buffer, value);
return make_bson_value(L, bson_type::BSON_OBJECTID, buffer, 12);
return make_bson_value(L, bson_type::BSON_OBJECTID, (uint8_t*)buffer, 12);
}

int pairs(lua_State* L) {
m_buffer.clean();
size_t data_len = 0;
char* data = (char*)encode_pairs(L, &data_len);
return make_bson_value(L, bson_type::BSON_DOCUMENT, data, data_len);
m_buffer.write<uint8_t>(0);
m_buffer.write<uint8_t>((uint8_t)bson_type::BSON_DOCUMENT);
uint8_t* data = encode_pairs(L, &data_len);
lua_pushlstring(L, (const char*)data, data_len);
return 1;
}

int binary(lua_State* L) {
m_buffer.clean();
size_t data_len = 0;
const char* value = lua_tolstring(L, 1, &data_len);
luaL_Buffer b;
luaL_buffinit(L, &b);
luaL_addchar(&b, 0);
luaL_addchar(&b, (uint8_t)bson_type::BSON_BINARY);
luaL_addchar(&b, 0);
luaL_addlstring(&b, value, data_len);
luaL_pushresult(&b);
uint8_t* value = (uint8_t*)lua_tolstring(L, 1, &data_len);
m_buffer.write<uint8_t>(0);
m_buffer.write<uint8_t>((uint8_t)bson_type::BSON_BINARY);
m_buffer.write<uint8_t>(0); //subtype
m_buffer.write<int32_t>(data_len);
m_buffer.push_data(value, data_len);
lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size());
return 1;
}

int regex(lua_State* L) {
luaL_Buffer b;
luaL_buffinit(L, &b);
luaL_addchar(&b, 0);
luaL_addchar(&b, (uint8_t)bson_type::BSON_REGEX);
lua_pushvalue(L,1);
luaL_addvalue(&b);
luaL_addchar(&b, 0);
lua_pushvalue(L,2);
luaL_addvalue(&b);
luaL_addchar(&b, 0);
luaL_pushresult(&b);
m_buffer.clean();
size_t data_len = 0;
m_buffer.write<uint8_t>(0);
m_buffer.write<uint8_t>((uint8_t)bson_type::BSON_REGEX);
uint8_t* val1 = (uint8_t*)lua_tolstring(L, 1, &data_len);
m_buffer.push_data(val1, data_len);
m_buffer.write<uint8_t>(0);
uint8_t* val2 = (uint8_t*)lua_tolstring(L, 2, &data_len);
m_buffer.push_data(val2, data_len);
m_buffer.write<uint8_t>(0);
lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size());
return 1;
}

protected:
int make_bson_value(lua_State *L, bson_type type, const char* ptr, size_t len) {
luaL_Buffer b;
luaL_buffinit(L, &b);
luaL_addchar(&b, 0);
luaL_addchar(&b, (uint8_t)type);
luaL_addlstring(&b, ptr, len);
luaL_pushresult(&b);
int make_bson_value(lua_State *L, bson_type type, uint8_t* value, size_t len) {
m_buffer.clean();
m_buffer.write<uint8_t>(0);
m_buffer.write<uint8_t>((uint8_t)type);
m_buffer.push_data(value, len);
lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size());
return 1;
}

Expand Down Expand Up @@ -545,12 +547,13 @@ namespace lbson {
break;
case bson_type::BSON_BINARY: {
lua_createtable(L, 0, 4);
int32_t len = read_val<int32_t>(L, slice);
lua_pushinteger(L, (uint32_t)bt);
lua_setfield(L, -2, "__type");
lua_pushinteger(L, read_val<uint8_t>(L, slice));
lua_setfield(L, -2, "subtype");
const char* s = read_bytes(L, slice, sz);
lua_pushlstring(L, s, sz);
const char* s = read_bytes(L, slice, len);
lua_pushlstring(L, s, len);
lua_setfield(L, -2, "binray");
}
break;
Expand Down Expand Up @@ -639,7 +642,7 @@ namespace lbson {
m_bson->unpack_dict(L, m_slice, false);
} catch (const exception& e){
lua_settop(L, otop);
throw e;
throw lua_exception(e.what());
}
return lua_gettop(L) - otop;
}
Expand Down
49 changes: 0 additions & 49 deletions core/plugins/src/lcodec/url.h

This file was deleted.

30 changes: 0 additions & 30 deletions extend/luaxlsx/test/test.lua

This file was deleted.

Binary file removed extend/luaxlsx/test/test.xlsx
Binary file not shown.
7 changes: 5 additions & 2 deletions script/agent/proxy_agent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ local ProxyAgent = singleton(thread)
local prop = property(ProxyAgent)
prop:reader("ignore_statistics", {})
prop:reader("statis_status", false)
prop:reader("cur_path", "")

function ProxyAgent:__init()
self.service = "proxy"
self.service = "proxy"
self.cur_path = stdfs.current_path()
--开启调度器
if scheduler then
self:startup("worker.proxy")
--开启统计
Expand All @@ -33,7 +36,7 @@ end

--日志分发
function ProxyAgent:dispatch_log(content, lvl_name)
local title = sformat("[%s][%s]", hive.name, lvl_name)
local title = sformat("[%s][%s][%s]", hive.name, lvl_name, self.cur_path)
return self:send("rpc_fire_webhook", title, content)
end

Expand Down
1 change: 1 addition & 0 deletions script/network/http_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function HttpServer:response(socket, status, response, headers)
local html = response:find("<html")
headers["Content-Type"] = html and "text/html" or "text/plain"
end
headers["connection"] = "close"
socket:send_data(status, headers, response)
self:close(token, socket)
end
Expand Down
29 changes: 0 additions & 29 deletions server/qtest/jps_test.lua

This file was deleted.

0 comments on commit 2dd5338

Please sign in to comment.