first stage of primary handling requests from secondary */
| 294 | |
| 295 | /* first stage of primary handling requests from secondary */ |
| 296 | static int |
| 297 | handle_request(const struct rte_mp_msg *msg, const void *peer __rte_unused) |
| 298 | { |
| 299 | const struct malloc_mp_req *m = |
| 300 | (const struct malloc_mp_req *)msg->param; |
| 301 | struct mp_request *entry; |
| 302 | int ret; |
| 303 | |
| 304 | /* lock access to request */ |
| 305 | pthread_mutex_lock(&mp_request_list.lock); |
| 306 | |
| 307 | /* make sure it's not a dupe */ |
| 308 | entry = find_request_by_id(m->id); |
| 309 | if (entry != NULL) { |
| 310 | RTE_LOG(ERR, EAL, "Duplicate request id\n"); |
| 311 | goto fail; |
| 312 | } |
| 313 | |
| 314 | entry = malloc(sizeof(*entry)); |
| 315 | if (entry == NULL) { |
| 316 | RTE_LOG(ERR, EAL, "Unable to allocate memory for request\n"); |
| 317 | goto fail; |
| 318 | } |
| 319 | |
| 320 | /* erase all data */ |
| 321 | memset(entry, 0, sizeof(*entry)); |
| 322 | |
| 323 | if (m->t == REQ_TYPE_ALLOC) { |
| 324 | ret = handle_alloc_request(m, entry); |
| 325 | } else if (m->t == REQ_TYPE_FREE) { |
| 326 | ret = handle_free_request(m); |
| 327 | } else { |
| 328 | RTE_LOG(ERR, EAL, "Unexpected request from secondary\n"); |
| 329 | goto fail; |
| 330 | } |
| 331 | |
| 332 | if (ret != 0) { |
| 333 | struct rte_mp_msg resp_msg; |
| 334 | struct malloc_mp_req *resp = |
| 335 | (struct malloc_mp_req *)resp_msg.param; |
| 336 | |
| 337 | /* send failure message straight away */ |
| 338 | resp_msg.num_fds = 0; |
| 339 | resp_msg.len_param = sizeof(*resp); |
| 340 | strlcpy(resp_msg.name, MP_ACTION_RESPONSE, |
| 341 | sizeof(resp_msg.name)); |
| 342 | |
| 343 | resp->t = m->t; |
| 344 | resp->result = REQ_RESULT_FAIL; |
| 345 | resp->id = m->id; |
| 346 | |
| 347 | if (rte_mp_sendmsg(&resp_msg)) { |
| 348 | RTE_LOG(ERR, EAL, "Couldn't send response\n"); |
| 349 | goto fail; |
| 350 | } |
| 351 | /* we did not modify the request */ |
| 352 | free(entry); |
| 353 | } else { |
nothing calls this directly
no test coverage detected