MCPcopy Create free account
hub / github.com/F-Stack/f-stack / handle_sync_response

Function handle_sync_response

dpdk/lib/eal/common/malloc_mp.c:402–548  ·  view source on GitHub ↗

callback for asynchronous sync requests for primary. this will either do a * sendmsg with results, or trigger rollback request. */

Source from the content-addressed store, hash-verified

400 * sendmsg with results, or trigger rollback request.
401 */
402static int
403handle_sync_response(const struct rte_mp_msg *request,
404 const struct rte_mp_reply *reply)
405{
406 enum malloc_req_result result;
407 struct mp_request *entry;
408 const struct malloc_mp_req *mpreq =
409 (const struct malloc_mp_req *)request->param;
410 int i;
411
412 /* lock the request */
413 pthread_mutex_lock(&mp_request_list.lock);
414
415 entry = find_request_by_id(mpreq->id);
416 if (entry == NULL) {
417 RTE_LOG(ERR, EAL, "Wrong request ID\n");
418 goto fail;
419 }
420
421 result = REQ_RESULT_SUCCESS;
422
423 if (reply->nb_received != reply->nb_sent)
424 result = REQ_RESULT_FAIL;
425
426 for (i = 0; i < reply->nb_received; i++) {
427 struct malloc_mp_req *resp =
428 (struct malloc_mp_req *)reply->msgs[i].param;
429
430 if (resp->t != REQ_TYPE_SYNC) {
431 RTE_LOG(ERR, EAL, "Unexpected response to sync request\n");
432 result = REQ_RESULT_FAIL;
433 break;
434 }
435 if (resp->id != entry->user_req.id) {
436 RTE_LOG(ERR, EAL, "Response to wrong sync request\n");
437 result = REQ_RESULT_FAIL;
438 break;
439 }
440 if (resp->result == REQ_RESULT_FAIL) {
441 result = REQ_RESULT_FAIL;
442 break;
443 }
444 }
445
446 if (entry->user_req.t == REQ_TYPE_FREE) {
447 struct rte_mp_msg msg;
448 struct malloc_mp_req *resp = (struct malloc_mp_req *)msg.param;
449
450 memset(&msg, 0, sizeof(msg));
451
452 /* this is a free request, just sendmsg result */
453 resp->t = REQ_TYPE_FREE;
454 resp->result = result;
455 resp->id = entry->user_req.id;
456 msg.num_fds = 0;
457 msg.len_param = sizeof(*resp);
458 strlcpy(msg.name, MP_ACTION_RESPONSE, sizeof(msg.name));
459

Callers

nothing calls this directly

Calls 10

pthread_mutex_lockFunction · 0.85
find_request_by_idFunction · 0.85
memsetFunction · 0.85
rollback_expand_heapFunction · 0.85
pthread_mutex_unlockFunction · 0.85
rte_mp_sendmsgFunction · 0.70
rte_mp_request_asyncFunction · 0.70
strlcpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected