v0.8.3 bugfix (#38)
* build: add compile options for Windows and include string header Set ssize_t definition for Windows builds to ensure compatibility. Include string header to support additional functionality in the grpc message handling. * build: reorganize CMake options for clarity Enhance CMake configuration by restructuring compilation options for MSVC and Windows. This improves readability and ensures compatibility with UTF-8 while maintaining the NOMINMAX definition on Windows. * fix: add GIL for pybind11::bytes object accessing Protect the access to the pybind11::bytes object with a GIL lock to avoid potential memory errors, and unify the handling of empty and non-empty strings. Eliminate unused functions for empty byte objects in the export channel and export RPC modules to enhance code clarity. * docs: update release notes and versioning Add release notes for versions 0.8.2 and 0.8.3, highlighting important fixes, including resolutions for platform-specific linking issues and stability improvements for multi-threaded RPC calls. Increment version to 0.8.3.
This commit is contained in:
parent
a4d8f83ce2
commit
e356e4d3e1
@ -88,6 +88,9 @@ if(AIMRT_MASTER_PROJECT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/utf-8 /wd4819)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
|
||||
@ -97,9 +100,6 @@ if(AIMRT_MASTER_PROJECT)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
endif()
|
||||
|
||||
# Build document
|
||||
if(AIMRT_BUILD_DOCUMENT)
|
||||
message(STATUS "gen document ...")
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
v0_8_0.md
|
||||
v0_8_1.md
|
||||
v0_8_2.md
|
||||
v0_8_3.md
|
||||
```
|
||||
|
||||
|
||||
|
4
document/sphinx-cn/release_notes/v0_8_2.md
Normal file
4
document/sphinx-cn/release_notes/v0_8_2.md
Normal file
@ -0,0 +1,4 @@
|
||||
# v0.8.2
|
||||
|
||||
**重要修改**
|
||||
- 修复某些平台上与 dl 库的链接问题
|
6
document/sphinx-cn/release_notes/v0_8_3.md
Normal file
6
document/sphinx-cn/release_notes/v0_8_3.md
Normal file
@ -0,0 +1,6 @@
|
||||
# v0.8.3
|
||||
|
||||
**重要修改**
|
||||
|
||||
- 修复 aimrt_py 多线程 rpc 调用 server 端概率性崩溃的问题
|
||||
- 修复了 windows 下源码引用的构建问题,以及 grpc_plugin 在 windows 下的构建问题
|
@ -37,6 +37,11 @@ target_link_libraries(
|
||||
aimrt::runtime::common::net
|
||||
nghttp2::nghttp2)
|
||||
|
||||
# Set compile options of target
|
||||
if(WIN32)
|
||||
target_compile_definitions(${CUR_TARGET_NAME} PRIVATE ssize_t=long)
|
||||
endif()
|
||||
|
||||
# Add -Werror option
|
||||
include(AddWerror)
|
||||
add_werror(${CUR_TARGET_NAME})
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace aimrt::plugins::grpc_plugin::grpc {
|
||||
|
@ -41,8 +41,6 @@ inline void ExportPublisherRef(pybind11::object m) {
|
||||
.def("Publish", &PyPublish);
|
||||
}
|
||||
|
||||
inline pybind11::bytes channel_empty_py_bytes;
|
||||
|
||||
inline bool PySubscribe(
|
||||
aimrt::channel::SubscriberRef& subscriber_ref,
|
||||
const std::shared_ptr<const PyTypeSupport>& msg_type_support,
|
||||
@ -61,17 +59,13 @@ inline bool PySubscribe(
|
||||
const std::string& msg_buf = *static_cast<const std::string*>(msg_ptr);
|
||||
auto ctx_ref = aimrt::channel::ContextRef(ctx_ptr);
|
||||
|
||||
if (msg_buf.empty()) [[unlikely]] {
|
||||
callback(ctx_ref.GetSerializationType(), channel_empty_py_bytes);
|
||||
} else {
|
||||
auto msg_buf_bytes = pybind11::bytes(msg_buf);
|
||||
|
||||
callback(ctx_ref.GetSerializationType(), msg_buf_bytes);
|
||||
|
||||
pybind11::gil_scoped_acquire acquire;
|
||||
|
||||
auto msg_buf_bytes = pybind11::bytes(msg_buf);
|
||||
callback(ctx_ref.GetSerializationType(), msg_buf_bytes);
|
||||
msg_buf_bytes.release();
|
||||
|
||||
pybind11::gil_scoped_release release;
|
||||
}
|
||||
|
||||
release_callback();
|
||||
});
|
||||
|
@ -89,8 +89,6 @@ inline void ExportRpcContext(const pybind11::object& m) {
|
||||
.def("ToString", &ContextRef::ToString);
|
||||
}
|
||||
|
||||
inline pybind11::bytes rpc_empty_py_bytes;
|
||||
|
||||
inline void PyRpcServiceBaseRegisterServiceFunc(
|
||||
aimrt::rpc::ServiceBase& service,
|
||||
std::string_view func_name,
|
||||
@ -112,29 +110,17 @@ inline void PyRpcServiceBaseRegisterServiceFunc(
|
||||
const std::string& req_buf = *static_cast<const std::string*>(req_ptr);
|
||||
std::string& rsp_buf = *static_cast<std::string*>(rsp_ptr);
|
||||
|
||||
// TODO,未知原因,在此处使用空字符串构造pybind11::bytes时会挂掉。但是在外面构造没有问题
|
||||
if (req_buf.empty()) [[unlikely]] {
|
||||
auto [status, rsp_buf_tmp] = service_func(ctx_ref, rpc_empty_py_bytes);
|
||||
|
||||
rsp_buf = std::move(rsp_buf_tmp);
|
||||
|
||||
callback_f(status.Code());
|
||||
return;
|
||||
} else {
|
||||
auto req_buf_bytes = pybind11::bytes(req_buf);
|
||||
|
||||
auto [status, rsp_buf_tmp] = service_func(ctx_ref, req_buf_bytes);
|
||||
|
||||
pybind11::gil_scoped_acquire acquire;
|
||||
|
||||
auto req_buf_bytes = pybind11::bytes(req_buf);
|
||||
auto [status, rsp_buf_tmp] = service_func(ctx_ref, req_buf_bytes);
|
||||
req_buf_bytes.release();
|
||||
|
||||
pybind11::gil_scoped_release release;
|
||||
|
||||
rsp_buf = std::move(rsp_buf_tmp);
|
||||
|
||||
callback_f(status.Code());
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
callback_f(AIMRT_RPC_STATUS_SVR_HANDLE_FAILED);
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user