src/dpdk/lib/librte_eal/common/malloc_mp.c
int
request_sync(void)
{
	struct rte_mp_msg msg;
	struct rte_mp_reply reply;
	struct malloc_mp_req *req = (struct malloc_mp_req *)msg.param;
	struct timespec ts;
	int i, ret = -1;

	memset(&msg, 0, sizeof(msg));
	memset(&reply, 0, sizeof(reply));

	/* no need to create tailq entries as this is entirely synchronous */

	msg.num_fds = 0;
	msg.len_param = sizeof(*req);
	strlcpy(msg.name, MP_ACTION_SYNC, sizeof(msg.name));

	/* sync request carries no data */
	req->t = REQ_TYPE_SYNC;
	req->id = get_unique_id();

	ts.tv_nsec = 0;
	ts.tv_sec = MP_TIMEOUT_S;

	/* there may be stray timeout still waiting */
	do {
		ret = rte_mp_request_sync(&msg, &reply, &ts);
	} while (ret != 0 && rte_errno == EEXIST);
	if (ret != 0) {
		/* if IPC is unsupported, behave as if the call succeeded */
		if (rte_errno != ENOTSUP)
			RTE_LOG(ERR, EAL, "Could not send sync request to secondary process\n");
		else
			ret = 0;
		goto out;
	}

	if (reply.nb_received != reply.nb_sent) {
		RTE_LOG(ERR, EAL, "Not all secondaries have responded\n");
		goto out;
	}

	for (i = 0; i < reply.nb_received; i++) {
		struct malloc_mp_req *resp =
				(struct malloc_mp_req *)reply.msgs[i].param;
		if (resp->t != REQ_TYPE_SYNC) {
			RTE_LOG(ERR, EAL, "Unexpected response from secondary\n");
			goto out;
		}
		if (resp->id != req->id) {
			RTE_LOG(ERR, EAL, "Wrong request ID\n");
			goto out;
		}
		if (resp->result != REQ_RESULT_SUCCESS) {
			RTE_LOG(ERR, EAL, "Secondary process failed to synchronize\n");
			goto out;
		}
	}

	ret = 0;
out:
	free(reply.msgs);
	return ret;
}
/* synchronously request memory map sync, this is only called whenever primary
 * process initiates the allocation.
 */
synchronously request memory map sync, this is only called whenever primary
process initiates the allocation.
synchronously request memory map sync this is only called whenever primary process initiates the allocation .
int
request_sync(void)
{
	struct rte_mp_msg msg;
	struct rte_mp_reply reply;
	struct malloc_mp_req *req = (struct malloc_mp_req *)msg.param;
	struct timespec ts;
	int i, ret = -1;
	memset(&msg, 0, sizeof(msg));
	memset(&reply, 0, sizeof(reply));
	msg.num_fds = 0;
	msg.len_param = sizeof(*req);
	strlcpy(msg.name, MP_ACTION_SYNC, sizeof(msg.name));
	req->t = REQ_TYPE_SYNC;
	req->id = get_unique_id();
	ts.tv_nsec = 0;
	ts.tv_sec = MP_TIMEOUT_S;
	do {
		ret = rte_mp_request_sync(&msg, &reply, &ts);
	} while (ret != 0 && rte_errno == EEXIST);
	if (ret != 0) {
		if (rte_errno != ENOTSUP)
			RTE_LOG(ERR, EAL, "Could not send sync request to secondary process\n");
		else
			ret = 0;
		goto out;
	}
	if (reply.nb_received != reply.nb_sent) {
		RTE_LOG(ERR, EAL, "Not all secondaries have responded\n");
		goto out;
	}
	for (i = 0; i < reply.nb_received; i++) {
		struct malloc_mp_req *resp =
				(struct malloc_mp_req *)reply.msgs[i].param;
		if (resp->t != REQ_TYPE_SYNC) {
			RTE_LOG(ERR, EAL, "Unexpected response from secondary\n");
			goto out;
		}
		if (resp->id != req->id) {
			RTE_LOG(ERR, EAL, "Wrong request ID\n");
			goto out;
		}
		if (resp->result != REQ_RESULT_SUCCESS) {
			RTE_LOG(ERR, EAL, "Secondary process failed to synchronize\n");
			goto out;
		}
	}
	ret = 0;
out:
	free(reply.msgs);
	return ret;
}
int request_sync ( void ) { struct rte_mp_msg msg ; struct rte_mp_reply reply ; struct malloc_mp_req * req = ( struct malloc_mp_req * ) msg . param ; struct timespec ts ; int i , ret = -1 ; memset ( & msg , 0 , sizeof ( msg ) ) ; memset ( & reply , 0 , sizeof ( reply ) ) ; msg . num_fds = 0 ; msg . len_param = sizeof ( * req ) ; strlcpy ( msg . name , MP_ACTION_SYNC , sizeof ( msg . name ) ) ; req -> t = REQ_TYPE_SYNC ; req -> id = get_unique_id ( ) ; ts . tv_nsec = 0 ; ts . tv_sec = MP_TIMEOUT_S ; do { ret = rte_mp_request_sync ( & msg , & reply , & ts ) ; } while ( ret != 0 && rte_errno == EEXIST ) ; if ( ret != 0 ) { if ( rte_errno != ENOTSUP ) RTE_LOG ( ERR , EAL , " \n " ) ; else ret = 0 ; goto out ; } if ( reply . nb_received != reply . nb_sent ) { RTE_LOG ( ERR , EAL , " \n " ) ; goto out ; } for ( i = 0 ; i < reply . nb_received ; i ++ ) { struct malloc_mp_req * resp = ( struct malloc_mp_req * ) reply . msgs [ i ] . param ; if ( resp -> t != REQ_TYPE_SYNC ) { RTE_LOG ( ERR , EAL , " \n " ) ; goto out ; } if ( resp -> id != req -> id ) { RTE_LOG ( ERR , EAL , " \n " ) ; goto out ; } if ( resp -> result != REQ_RESULT_SUCCESS ) { RTE_LOG ( ERR , EAL , " \n " ) ; goto out ; } } ret = 0 ; out : free ( reply . msgs ) ; return ret ; }
synchronously request memory map sync, this is only called whenever primary
 process initiates the allocation.
synchronously request memory map sync this is only called whenever primary process initiates the allocation .
/* no need to create tailq entries as this is entirely synchronous */ /* sync request carries no data */ /* there may be stray timeout still waiting */ /* if IPC is unsupported, behave as if the call succeeded */