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

Function mp_send

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

Source from the content-addressed store, hash-verified

741}
742
743static int
744mp_send(struct rte_mp_msg *msg, const char *peer, int type)
745{
746 int dir_fd, ret = 0;
747 DIR *mp_dir;
748 struct dirent *ent;
749
750 if (!peer && (rte_eal_process_type() == RTE_PROC_SECONDARY))
751 peer = eal_mp_socket_path();
752
753 if (peer) {
754 if (send_msg(peer, msg, type) < 0)
755 return -1;
756 else
757 return 0;
758 }
759
760 /* broadcast to all secondary processes */
761 mp_dir = opendir(mp_dir_path);
762 if (!mp_dir) {
763 RTE_LOG(ERR, EAL, "Unable to open directory %s\n",
764 mp_dir_path);
765 rte_errno = errno;
766 return -1;
767 }
768
769 dir_fd = dirfd(mp_dir);
770 /* lock the directory to prevent processes spinning up while we send */
771 if (flock(dir_fd, LOCK_SH)) {
772 RTE_LOG(ERR, EAL, "Unable to lock directory %s\n",
773 mp_dir_path);
774 rte_errno = errno;
775 closedir(mp_dir);
776 return -1;
777 }
778
779 while ((ent = readdir(mp_dir))) {
780 char path[PATH_MAX];
781
782 if (fnmatch(mp_filter, ent->d_name, 0) != 0)
783 continue;
784
785 snprintf(path, sizeof(path), "%s/%s", mp_dir_path,
786 ent->d_name);
787 if (send_msg(path, msg, type) < 0)
788 ret = -1;
789 }
790 /* unlock the dir */
791 flock(dir_fd, LOCK_UN);
792
793 /* dir_fd automatically closed on closedir */
794 closedir(mp_dir);
795 return ret;
796}
797
798static int
799check_input(const struct rte_mp_msg *msg)

Callers 3

process_msgFunction · 0.85
rte_mp_sendmsgFunction · 0.85
rte_mp_replyFunction · 0.85

Calls 9

rte_eal_process_typeFunction · 0.85
eal_mp_socket_pathFunction · 0.85
opendirFunction · 0.85
closedirFunction · 0.85
readdirFunction · 0.85
snprintfFunction · 0.85
send_msgFunction · 0.70
flockClass · 0.50
fnmatchFunction · 0.50

Tested by

no test coverage detected