1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #307, support sendmmsg to improve RTC performance

This commit is contained in:
winlin 2020-04-04 22:43:44 +08:00
parent 3793404ceb
commit 55a4052d90
8 changed files with 107 additions and 9 deletions

View file

@ -743,6 +743,36 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
}
int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
{
int n;
int left;
struct mmsghdr *p;
left = (int)vlen;
while (left > 0) {
p = msgvec + (vlen - left);
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
break;
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
break;
}
left -= n;
}
// An error is returned only if no datagrams could be sent.
if (left == (int)vlen) {
return n;
}
return (int)vlen - left;
}
/*
* To open FIFOs or other special files.