MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / processReceive

Method processReceive

libapp2sys/src/main/cpp/protocol.h:332–537  ·  view source on GitHub ↗

#lizard forgives

Source from the content-addressed store, hash-verified

330
331 // #lizard forgives
332 int64_t processReceive(int uid, T *r, AMCReqHeader *pHead, uint8_t *payload, uint32_t payloadLen, HardCoder *inst) {
333 if (r == NULL || (payload == NULL && payloadLen != 0)) {
334 perr("recvEvent DATA data or addr invalid ret len:%d, %d", payloadLen, TOINT(sizeof(AMCReqHeader)));
335 return -1;
336 }
337
338 remote = *r;
339
340 if (pHead->version < HEADER_PROTOCAL_VERSION) {
341 perr("CheckVersion failed:%d server:%d", pHead->version, HEADER_PROTOCAL_VERSION);
342 return genRespPack(pHead->funcid, ERR_CLIENT_UPGRADE_REQUIRED, pHead->requestid, NULL, 0, &resp, &respLen);;
343 }
344
345// if (!inst->checkPermission(pHead->funcid, uid, pHead->callertid, pHead->timestamp)) {
346// perr("checkPermission[%d, %d] failed ret ERR_UNAUTHORIZED", pHead->funcid, uid);
347// genRespPack(pHead->funcid, ERR_UNAUTHORIZED, 0, NULL, 0, &resp, &respLen);
348// return 0;
349// }
350
351 if (pHead->funcid == FUNC_CHECK_PERMISSION) {
352 amc::CheckPermission p;
353 int ret = p.ParseFromArray(payload, payloadLen);
354 std::vector<std::string> vec1;
355 std::vector<std::string> vec2;
356 if (ret) {
357 int size = p.certtags_size();
358 for (int i = 0; i < size; i++) {
359 vec1.push_back(p.certtags(i).manufacture());
360 vec2.push_back(p.certtags(i).cert());
361 }
362 }
363 int respResult = inst->checkPermission(vec1, vec2, pHead->funcid, uid, pHead->callertid, pHead->timestamp) ? 0 : ERR_UNAUTHORIZED;
364 pdbg("FUNC_CHECK_PERMISSION [%d,%d] resp:%d", pHead->funcid, uid, respResult);
365 return genRespPack(pHead->funcid, respResult, pHead->requestid, NULL, 0, &resp, &respLen);;
366 }
367
368 if (pHead->funcid == FUNC_UNIFY_CPU_IO_THREAD_CORE_GPU) {
369 amc::RequestUnifyCPUIOThreadCore p;
370 int ret = p.ParseFromArray(payload, payloadLen);
371 std::vector<int> vec;
372 if (ret) {
373 int size = p.bindtids_size();
374 for (int i = 0; i < size; i++) {
375 vec.push_back(p.bindtids(i));
376 }
377 }
378 int respResult = ret ? inst->requestUnifyCpuIOThreadCoreGpu(p.scene(),p.action(), p.cpulevel(), p.iolevel(), vec, p.gpulevel(), p.timeoutms(), pHead->callertid, pHead->timestamp) : ERR_PACKAGE_DECODE_FAILED;
379 pdbg("FUNC_UNIFY_CPU_IO_THREAD_CORE parse:%d [%d,%d,%d,%d,%d,%d,%d] resp:%d", ret, p.scene(), TOINT(p.action()), p.cpulevel(), p.iolevel(), TOINT(p.bindtids_size()), p.gpulevel(), p.timeoutms(), respResult);
380 return genRespPack(pHead->funcid, respResult, pHead->requestid, NULL, 0, &resp, &respLen);
381 }
382
383 if (pHead->funcid == FUNC_CANCEL_UNIFY_CPU_IO_THREAD_CORE_GPU) {
384 amc::CancelUnifyCPUIOThreadCore p;
385 int ret = p.ParseFromArray(payload, payloadLen);
386 std::vector<int> vec;
387 if (ret) {
388 int size = p.bindtids_size();
389 for (int i = 0; i < size; i++) {

Callers

nothing calls this directly

Calls 15

genRespPackFunction · 0.85
checkPermissionMethod · 0.45
requestCpuHighFreqMethod · 0.45
cancelCpuHighFreqMethod · 0.45
requestGpuHighFreqMethod · 0.45
cancelGpuHighFreqMethod · 0.45
requestHighIOFreqMethod · 0.45
cancelHighIOFreqMethod · 0.45

Tested by

no test coverage detected