src/dpdk/lib/librte_eal/common/eal_common_proc.c
static int
send_msg(const char *dst_path, struct rte_mp_msg *msg, int type)
{
	int snd;
	struct iovec iov;
	struct msghdr msgh;
	struct cmsghdr *cmsg;
	struct sockaddr_un dst;
	struct mp_msg_internal m;
	int fd_size = msg->num_fds * sizeof(int);
	char control[CMSG_SPACE(fd_size)];

	m.type = type;
	memcpy(&m.msg, msg, sizeof(*msg));

	memset(&dst, 0, sizeof(dst));
	dst.sun_family = AF_UNIX;
	strlcpy(dst.sun_path, dst_path, sizeof(dst.sun_path));

	memset(&msgh, 0, sizeof(msgh));
	memset(control, 0, sizeof(control));

	iov.iov_base = &m;
	iov.iov_len = sizeof(m) - sizeof(msg->fds);

	msgh.msg_name = &dst;
	msgh.msg_namelen = sizeof(dst);
	msgh.msg_iov = &iov;
	msgh.msg_iovlen = 1;
	msgh.msg_control = control;
	msgh.msg_controllen = sizeof(control);

	cmsg = CMSG_FIRSTHDR(&msgh);
	cmsg->cmsg_len = CMSG_LEN(fd_size);
	cmsg->cmsg_level = SOL_SOCKET;
	cmsg->cmsg_type = SCM_RIGHTS;
	memcpy(CMSG_DATA(cmsg), msg->fds, fd_size);

	do {
		snd = sendmsg(mp_fd, &msgh, 0);
	} while (snd < 0 && errno == EINTR);

	if (snd < 0) {
		rte_errno = errno;
		/* Check if it caused by peer process exits */
		if (errno == ECONNREFUSED &&
				rte_eal_process_type() == RTE_PROC_PRIMARY) {
			unlink(dst_path);
			return 0;
		}
		RTE_LOG(ERR, EAL, "failed to send to (%s) due to %s\n",
			dst_path, strerror(errno));
		return -1;
	}

	return 1;
}
/**
 * Return -1, as fail to send message and it's caused by the local side.
 * Return 0, as fail to send message and it's caused by the remote side.
 * Return 1, as succeed to send message.
 *
 */
1, as fail to send message and it's caused by the local side.
Return 0, as fail to send message and it's caused by the remote side.
Return 1, as succeed to send message.
1 as fail to send message and it ' s caused by the local side . Return 0 as fail to send message and it ' s caused by the remote side . Return 1 as succeed to send message .
static int
send_msg(const char *dst_path, struct rte_mp_msg *msg, int type)
{
	int snd;
	struct iovec iov;
	struct msghdr msgh;
	struct cmsghdr *cmsg;
	struct sockaddr_un dst;
	struct mp_msg_internal m;
	int fd_size = msg->num_fds * sizeof(int);
	char control[CMSG_SPACE(fd_size)];
	m.type = type;
	memcpy(&m.msg, msg, sizeof(*msg));
	memset(&dst, 0, sizeof(dst));
	dst.sun_family = AF_UNIX;
	strlcpy(dst.sun_path, dst_path, sizeof(dst.sun_path));
	memset(&msgh, 0, sizeof(msgh));
	memset(control, 0, sizeof(control));
	iov.iov_base = &m;
	iov.iov_len = sizeof(m) - sizeof(msg->fds);
	msgh.msg_name = &dst;
	msgh.msg_namelen = sizeof(dst);
	msgh.msg_iov = &iov;
	msgh.msg_iovlen = 1;
	msgh.msg_control = control;
	msgh.msg_controllen = sizeof(control);
	cmsg = CMSG_FIRSTHDR(&msgh);
	cmsg->cmsg_len = CMSG_LEN(fd_size);
	cmsg->cmsg_level = SOL_SOCKET;
	cmsg->cmsg_type = SCM_RIGHTS;
	memcpy(CMSG_DATA(cmsg), msg->fds, fd_size);
	do {
		snd = sendmsg(mp_fd, &msgh, 0);
	} while (snd < 0 && errno == EINTR);
	if (snd < 0) {
		rte_errno = errno;
		if (errno == ECONNREFUSED &&
				rte_eal_process_type() == RTE_PROC_PRIMARY) {
			unlink(dst_path);
			return 0;
		}
		RTE_LOG(ERR, EAL, "failed to send to (%s) due to %s\n",
			dst_path, strerror(errno));
		return -1;
	}
	return 1;
}
static int send_msg ( const char * dst_path , struct rte_mp_msg * msg , int type ) { int snd ; struct iovec iov ; struct msghdr msgh ; struct cmsghdr * cmsg ; struct sockaddr_un dst ; struct mp_msg_internal m ; int fd_size = msg -> num_fds * sizeof ( int ) ; char control [ CMSG_SPACE ( fd_size ) ] ; m . type = type ; memcpy ( & m . msg , msg , sizeof ( * msg ) ) ; memset ( & dst , 0 , sizeof ( dst ) ) ; dst . sun_family = AF_UNIX ; strlcpy ( dst . sun_path , dst_path , sizeof ( dst . sun_path ) ) ; memset ( & msgh , 0 , sizeof ( msgh ) ) ; memset ( control , 0 , sizeof ( control ) ) ; iov . iov_base = & m ; iov . iov_len = sizeof ( m ) - sizeof ( msg -> fds ) ; msgh . msg_name = & dst ; msgh . msg_namelen = sizeof ( dst ) ; msgh . msg_iov = & iov ; msgh . msg_iovlen = 1 ; msgh . msg_control = control ; msgh . msg_controllen = sizeof ( control ) ; cmsg = CMSG_FIRSTHDR ( & msgh ) ; cmsg -> cmsg_len = CMSG_LEN ( fd_size ) ; cmsg -> cmsg_level = SOL_SOCKET ; cmsg -> cmsg_type = SCM_RIGHTS ; memcpy ( CMSG_DATA ( cmsg ) , msg -> fds , fd_size ) ; do { snd = sendmsg ( mp_fd , & msgh , 0 ) ; } while ( snd < 0 && errno == EINTR ) ; if ( snd < 0 ) { rte_errno = errno ; if ( errno == ECONNREFUSED && rte_eal_process_type ( ) == RTE_PROC_PRIMARY ) { unlink ( dst_path ) ; return 0 ; } RTE_LOG ( ERR , EAL , " \n " , dst_path , strerror ( errno ) ) ; return -1 ; } return 1 ; }
Return -1, as fail to send message and it's caused by the local side.
Return - 1 as fail to send message and it ' s caused by the local side .
/* Check if it caused by peer process exits */