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

Function handle_request

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

first stage of primary handling requests from secondary */

Source from the content-addressed store, hash-verified

294
295/* first stage of primary handling requests from secondary */
296static int
297handle_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 {

Callers

nothing calls this directly

Calls 12

pthread_mutex_lockFunction · 0.85
find_request_by_idFunction · 0.85
mallocFunction · 0.85
memsetFunction · 0.85
handle_alloc_requestFunction · 0.85
handle_free_requestFunction · 0.85
pthread_mutex_unlockFunction · 0.85
rte_mp_sendmsgFunction · 0.70
rte_mp_request_asyncFunction · 0.70
strlcpyFunction · 0.50
freeFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected