MCPcopy Create free account
hub / github.com/caozhiyi/CppNet / _DoRead

Method _DoRead

test/rpc/RPCServer.cpp:66–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void CRPCServer::_DoRead(const cppnet::Handle& handle, base::CBuffer* data,
67 uint32_t len, uint32_t err) {
68 if (err != cppnet::CEC_SUCCESS) {
69 base::LOG_ERROR("read data failed! err : %d", err);
70 return;
71 }
72 int need_len = 0;
73 for (;;) {
74 char recv_buf[4096] = { 0 };
75 int read_len = data->ReadUntil(recv_buf, 4096, "\r\n\r\n", strlen("\r\n\r\n"), need_len);
76 //get a comlete message
77 if (read_len > 0) {
78 FuncCallInfo* info = _pool.PoolNew<FuncCallInfo>();
79 if (_need_mutex) {
80 std::unique_lock<std::mutex> lock(_mutex);
81 if (_parse_package->ParseFuncCall(recv_buf + 2, read_len - 2, info->_func_name, _func_map, info->_func_param_ret)) {
82 info->_socket = handle;
83 _info_router->PushTask(info);
84 } else {
85 base::LOG_ERROR("parse function call request failed!");
86 }
87
88 } else {
89 if (_parse_package->ParseFuncCall(recv_buf + 2, read_len - 2, info->_func_name, _func_map, info->_func_param_ret)) {
90 info->_socket = handle;
91 _info_router->PushTask(info);
92 } else {
93 base::LOG_ERROR("parse function call request failed!");
94 }
95 }
96
97 } else {
98 break;
99 }
100 }
101}
102
103void CRPCServer::_DoWrite(const cppnet::Handle&, uint32_t, uint32_t err) {
104 if (err != cppnet::CEC_SUCCESS) {

Callers

nothing calls this directly

Calls 3

ParseFuncCallMethod · 0.80
PushTaskMethod · 0.80
ReadUntilMethod · 0.45

Tested by

no test coverage detected