提交 ac853fdd 编写于 作者: Y yaoweifeng01 提交者: Xiangquan Xiao

cyber: fix py_server dereferenceAfterCheck

上级 16d6b273
......@@ -30,15 +30,18 @@ using apollo::cyber::proto::Chatter;
using apollo::cyber::message::PyMessageWrap;
apollo::cyber::PyService *server = nullptr;
int service_callback(const char *channel_name) {
AINFO << "server recv->[ " << channel_name << " ]";
if (server) {
Chatter chat;
std::string res = server->read();
chat.ParseFromString(res);
AINFO << "server read: responese: " << chat.ShortDebugString();
if (server == nullptr) {
AERROR << "server is null.";
return -1;
}
AINFO << "server recv channelname ->[ " << channel_name << " ]";
Chatter chat;
std::string res = server->read();
chat.ParseFromString(res);
AINFO << "server read: responese: " << chat.ShortDebugString();
Chatter driver_msg;
static uint64_t id = 0;
++id;
......@@ -47,7 +50,7 @@ int service_callback(const char *channel_name) {
std::string org_data;
driver_msg.SerializeToString(&org_data);
server->write(org_data);
return -1;
return 1;
}
int main(int argc, char *argv[]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册