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

Function mp_request_sync

dpdk/lib/eal/common/eal_common_proc.c:919–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

917}
918
919static int
920mp_request_sync(const char *dst, struct rte_mp_msg *req,
921 struct rte_mp_reply *reply, const struct timespec *ts)
922{
923 int ret;
924 pthread_condattr_t attr;
925 struct rte_mp_msg msg, *tmp;
926 struct pending_request pending_req, *exist;
927
928 pending_req.type = REQUEST_TYPE_SYNC;
929 pending_req.reply_received = 0;
930 strlcpy(pending_req.dst, dst, sizeof(pending_req.dst));
931 pending_req.request = req;
932 pending_req.reply = &msg;
933 pthread_condattr_init(&attr);
934 pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
935 pthread_cond_init(&pending_req.sync.cond, &attr);
936
937 exist = find_pending_request(dst, req->name);
938 if (exist) {
939 RTE_LOG(ERR, EAL, "A pending request %s:%s\n", dst, req->name);
940 rte_errno = EEXIST;
941 return -1;
942 }
943
944 ret = send_msg(dst, req, MP_REQ);
945 if (ret < 0) {
946 RTE_LOG(ERR, EAL, "Fail to send request %s:%s\n",
947 dst, req->name);
948 return -1;
949 } else if (ret == 0)
950 return 0;
951
952 TAILQ_INSERT_TAIL(&pending_requests.requests, &pending_req, next);
953
954 reply->nb_sent++;
955
956 do {
957 ret = pthread_cond_timedwait(&pending_req.sync.cond,
958 &pending_requests.lock, ts);
959 } while (ret != 0 && ret != ETIMEDOUT);
960
961 TAILQ_REMOVE(&pending_requests.requests, &pending_req, next);
962
963 if (pending_req.reply_received == 0) {
964 RTE_LOG(ERR, EAL, "Fail to recv reply for request %s:%s\n",
965 dst, req->name);
966 rte_errno = ETIMEDOUT;
967 return -1;
968 }
969 if (pending_req.reply_received == -1) {
970 RTE_LOG(DEBUG, EAL, "Asked to ignore response\n");
971 /* not receiving this message is not an error, so decrement
972 * number of sent messages
973 */
974 reply->nb_sent--;
975 return 0;
976 }

Callers 1

rte_mp_request_syncFunction · 0.85

Calls 5

find_pending_requestFunction · 0.85
send_msgFunction · 0.70
strlcpyFunction · 0.50
reallocFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected