mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #2188: Remove sendmmsg from ST.
This commit is contained in:
parent
d7bc8b98fb
commit
cec588e08a
9 changed files with 3 additions and 116 deletions
4
trunk/3rdparty/st-srs/Makefile
vendored
4
trunk/3rdparty/st-srs/Makefile
vendored
|
@ -282,10 +282,6 @@ endif
|
|||
#
|
||||
# make EXTRA_CFLAGS=-UMD_HAVE_EPOLL <target>
|
||||
#
|
||||
# or to enable sendmmsg(2) support:
|
||||
#
|
||||
# make EXTRA_CFLAGS="-DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
|
||||
#
|
||||
# or to enable stats for ST:
|
||||
#
|
||||
# make EXTRA_CFLAGS=-DDEBUG_STATS
|
||||
|
|
2
trunk/3rdparty/st-srs/README.md
vendored
2
trunk/3rdparty/st-srs/README.md
vendored
|
@ -66,7 +66,7 @@ The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patche
|
|||
- [x] Support macro `MD_ST_NO_ASM` to disable ASM, [#8](https://github.com/ossrs/state-threads/issues/8).
|
||||
- [x] Merge patch [srs#1282](https://github.com/ossrs/srs/issues/1282#issuecomment-445539513) to support aarch64, [#9](https://github.com/ossrs/state-threads/issues/9).
|
||||
- [x] Support OSX for Apple Darwin, macOS, [#11](https://github.com/ossrs/state-threads/issues/11).
|
||||
- [x] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
|
||||
- [ ] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
|
||||
- [x] Refine performance for sleep or epoll_wait(0), [#17](https://github.com/ossrs/state-threads/issues/17).
|
||||
- [ ] Improve the performance of timer. [9fe8cfe5b](https://github.com/ossrs/state-threads/commit/9fe8cfe5b1c9741a2e671a46215184f267fba400), [7879c2b](https://github.com/ossrs/state-threads/commit/7879c2b), [387cddb](https://github.com/ossrs/state-threads/commit/387cddb)
|
||||
|
||||
|
|
65
trunk/3rdparty/st-srs/io.c
vendored
65
trunk/3rdparty/st-srs/io.c
vendored
|
@ -68,8 +68,6 @@ unsigned long long _st_stat_recvmsg = 0;
|
|||
unsigned long long _st_stat_recvmsg_eagain = 0;
|
||||
unsigned long long _st_stat_sendmsg = 0;
|
||||
unsigned long long _st_stat_sendmsg_eagain = 0;
|
||||
unsigned long long _st_stat_sendmmsg = 0;
|
||||
unsigned long long _st_stat_sendmmsg_eagain = 0;
|
||||
#endif
|
||||
|
||||
#if EAGAIN != EWOULDBLOCK
|
||||
|
@ -833,69 +831,6 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
|
|||
return n;
|
||||
}
|
||||
|
||||
int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
|
||||
{
|
||||
#if defined(MD_HAVE_SENDMMSG) && defined(_GNU_SOURCE)
|
||||
int n;
|
||||
int left;
|
||||
struct mmsghdr *p;
|
||||
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmmsg;
|
||||
#endif
|
||||
|
||||
left = (int)vlen;
|
||||
while (left > 0) {
|
||||
p = (struct mmsghdr*)msgvec + (vlen - left);
|
||||
|
||||
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (!_IO_NOT_READY_ERROR)
|
||||
break;
|
||||
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmmsg_eagain;
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
#else
|
||||
struct st_mmsghdr *p;
|
||||
int i, n;
|
||||
|
||||
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
||||
for (i = 0; i < (int)vlen; ++i) {
|
||||
p = msgvec + i;
|
||||
n = st_sendmsg(fd, &p->msg_hdr, flags, timeout);
|
||||
if (n < 0) {
|
||||
// An error is returned only if no datagrams could be sent.
|
||||
if (i == 0) {
|
||||
return n;
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
p->msg_len = n;
|
||||
}
|
||||
|
||||
// Returns the number of messages sent from msgvec; if this is less than vlen, the caller can retry with a
|
||||
// further sendmmsg() call to send the remaining messages.
|
||||
return vlen;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* To open FIFOs or other special files.
|
||||
|
|
8
trunk/3rdparty/st-srs/public.h
vendored
8
trunk/3rdparty/st-srs/public.h
vendored
|
@ -153,14 +153,6 @@ extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct socka
|
|||
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
|
||||
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
|
||||
|
||||
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
||||
#include <sys/socket.h>
|
||||
struct st_mmsghdr {
|
||||
struct msghdr msg_hdr; /* Message header */
|
||||
unsigned int msg_len; /* Number of bytes transmitted */
|
||||
};
|
||||
extern int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
|
||||
|
||||
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue