Skip to content

Commit 34dae0f

Browse files
committed
For ossrs#2188: Remove sendmmsg from ST.
1 parent 20374ea commit 34dae0f

File tree

9 files changed

+3
-116
lines changed

9 files changed

+3
-116
lines changed

trunk/3rdparty/st-srs/Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ endif
282282
#
283283
# make EXTRA_CFLAGS=-UMD_HAVE_EPOLL <target>
284284
#
285-
# or to enable sendmmsg(2) support:
286-
#
287-
# make EXTRA_CFLAGS="-DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
288-
#
289285
# or to enable stats for ST:
290286
#
291287
# make EXTRA_CFLAGS=-DDEBUG_STATS

trunk/3rdparty/st-srs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patche
6666
- [x] Support macro `MD_ST_NO_ASM` to disable ASM, [#8](https://github.com/ossrs/state-threads/issues/8).
6767
- [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).
6868
- [x] Support OSX for Apple Darwin, macOS, [#11](https://github.com/ossrs/state-threads/issues/11).
69-
- [x] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
69+
- [ ] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
7070
- [x] Refine performance for sleep or epoll_wait(0), [#17](https://github.com/ossrs/state-threads/issues/17).
7171
- [ ] 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)
7272

trunk/3rdparty/st-srs/io.c

-65
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ unsigned long long _st_stat_recvmsg = 0;
6868
unsigned long long _st_stat_recvmsg_eagain = 0;
6969
unsigned long long _st_stat_sendmsg = 0;
7070
unsigned long long _st_stat_sendmsg_eagain = 0;
71-
unsigned long long _st_stat_sendmmsg = 0;
72-
unsigned long long _st_stat_sendmmsg_eagain = 0;
7371
#endif
7472

7573
#if EAGAIN != EWOULDBLOCK
@@ -833,69 +831,6 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
833831
return n;
834832
}
835833

836-
int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
837-
{
838-
#if defined(MD_HAVE_SENDMMSG) && defined(_GNU_SOURCE)
839-
int n;
840-
int left;
841-
struct mmsghdr *p;
842-
843-
#if defined(DEBUG) && defined(DEBUG_STATS)
844-
++_st_stat_sendmmsg;
845-
#endif
846-
847-
left = (int)vlen;
848-
while (left > 0) {
849-
p = (struct mmsghdr*)msgvec + (vlen - left);
850-
851-
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
852-
if (errno == EINTR)
853-
continue;
854-
if (!_IO_NOT_READY_ERROR)
855-
break;
856-
857-
#if defined(DEBUG) && defined(DEBUG_STATS)
858-
++_st_stat_sendmmsg_eagain;
859-
#endif
860-
861-
/* Wait until the socket becomes writable */
862-
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
863-
break;
864-
}
865-
866-
left -= n;
867-
}
868-
869-
// An error is returned only if no datagrams could be sent.
870-
if (left == (int)vlen) {
871-
return n;
872-
}
873-
return (int)vlen - left;
874-
#else
875-
struct st_mmsghdr *p;
876-
int i, n;
877-
878-
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
879-
for (i = 0; i < (int)vlen; ++i) {
880-
p = msgvec + i;
881-
n = st_sendmsg(fd, &p->msg_hdr, flags, timeout);
882-
if (n < 0) {
883-
// An error is returned only if no datagrams could be sent.
884-
if (i == 0) {
885-
return n;
886-
}
887-
return i + 1;
888-
}
889-
890-
p->msg_len = n;
891-
}
892-
893-
// Returns the number of messages sent from msgvec; if this is less than vlen, the caller can retry with a
894-
// further sendmmsg() call to send the remaining messages.
895-
return vlen;
896-
#endif
897-
}
898-
899834

900835
/*
901836
* To open FIFOs or other special files.

trunk/3rdparty/st-srs/public.h

-8
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct socka
153153
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
154154
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
155155

156-
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
157-
#include <sys/socket.h>
158-
struct st_mmsghdr {
159-
struct msghdr msg_hdr; /* Message header */
160-
unsigned int msg_len; /* Number of bytes transmitted */
161-
};
162-
extern int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
163-
164156
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
165157

166158
#ifdef DEBUG

trunk/auto/depends.sh

-8
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,6 @@ fi
348348
if [[ $SRS_OSX == YES ]]; then
349349
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_`uname -r`_DBG"
350350
fi
351-
# For UDP sendmmsg, disable it if not suppported.
352-
if [[ $SRS_SENDMMSG == YES ]]; then
353-
echo "Build ST with UDP sendmmsg support."
354-
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
355-
else
356-
echo "Build ST without UDP sendmmsg support."
357-
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -UMD_HAVE_SENDMMSG -U_GNU_SOURCE"
358-
fi
359351
# Whether enable debug stats.
360352
if [[ $SRS_DEBUG_STATS == YES ]]; then
361353
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DDEBUG_STATS"

trunk/auto/options.sh

-10
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ SRS_EXTRA_FLAGS=
128128
# Performance optimize.
129129
SRS_NASM=YES
130130
SRS_SRTP_ASM=YES
131-
SRS_SENDMMSG=NO
132131
SRS_DEBUG=NO
133132
SRS_DEBUG_STATS=NO
134133

@@ -177,7 +176,6 @@ Performance: @see https://blog.csdn.net/win_lin/article/details/5
177176
178177
--nasm=on|off Whether build FFMPEG for RTC with nasm. Default: $(value2switch $SRS_NASM)
179178
--srtp-nasm=on|off Whether build SRTP with ASM(openssl-asm), requires RTC and openssl-1.0.*. Default: $(value2switch $SRS_SRTP_ASM)
180-
--sendmmsg=on|off Whether enable UDP sendmmsg. Default: $(value2switch $SRS_SENDMMSG). @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
181179
182180
Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411
183181
--static=on|off Whether add '-static' to link options. Default: $(value2switch $SRS_STATIC)
@@ -230,8 +228,6 @@ function parse_user_option() {
230228
--x86-64) SRS_X86_X64=YES ;;
231229
--osx) SRS_OSX=YES ;;
232230

233-
--sendmmsg) if [[ $value == off ]]; then SRS_SENDMMSG=NO; else SRS_SENDMMSG=YES; fi ;;
234-
235231
--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
236232
--with-srtp-nasm) SRS_SRTP_ASM=YES ;;
237233
--srtp-nasm) if [[ $value == off ]]; then SRS_SRTP_ASM=NO; else SRS_SRTP_ASM=YES; fi ;;
@@ -523,11 +519,6 @@ function apply_detail_options() {
523519
echo "Use openssl-1.0 for SRTP-ASM."
524520
SRS_SSL_1_0=YES
525521
fi
526-
527-
if [[ $SRS_OSX == YES && $SRS_SENDMMSG == YES ]]; then
528-
echo "Disable sendmmsg for OSX"
529-
SRS_SENDMMSG=NO
530-
fi
531522
}
532523
apply_detail_options
533524

@@ -562,7 +553,6 @@ function regenerate_options() {
562553
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=$(value2switch $SRS_FFMPEG_FIT)"
563554
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=$(value2switch $SRS_NASM)"
564555
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=$(value2switch $SRS_SRTP_ASM)"
565-
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=$(value2switch $SRS_SENDMMSG)"
566556
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=$(value2switch $SRS_CLEAN)"
567557
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=$(value2switch $SRS_GPERF)"
568558
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=$(value2switch $SRS_GPERF_MC)"

trunk/src/app/srs_app_hybrid.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ extern unsigned long long _st_stat_recvmsg;
6666
extern unsigned long long _st_stat_recvmsg_eagain;
6767
extern unsigned long long _st_stat_sendmsg;
6868
extern unsigned long long _st_stat_sendmsg_eagain;
69-
extern unsigned long long _st_stat_sendmmsg;
70-
extern unsigned long long _st_stat_sendmmsg_eagain;
7169
SrsPps* _srs_pps_recvmsg = new SrsPps();
7270
SrsPps* _srs_pps_recvmsg_eagain = new SrsPps();
7371
SrsPps* _srs_pps_sendmsg = new SrsPps();
7472
SrsPps* _srs_pps_sendmsg_eagain = new SrsPps();
75-
SrsPps* _srs_pps_sendmmsg = new SrsPps();
76-
SrsPps* _srs_pps_sendmmsg_eagain = new SrsPps();
7773

7874
extern unsigned long long _st_stat_epoll;
7975
extern unsigned long long _st_stat_epoll_zero;
@@ -331,9 +327,8 @@ srs_error_t SrsHybridServer::notify(int event, srs_utime_t interval, srs_utime_t
331327
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
332328
_srs_pps_recvmsg->update(_st_stat_recvmsg); _srs_pps_recvmsg_eagain->update(_st_stat_recvmsg_eagain);
333329
_srs_pps_sendmsg->update(_st_stat_sendmsg); _srs_pps_sendmsg_eagain->update(_st_stat_sendmsg_eagain);
334-
_srs_pps_sendmmsg->update(_st_stat_sendmmsg); _srs_pps_sendmmsg_eagain->update(_st_stat_sendmmsg_eagain);
335-
if (_srs_pps_recvmsg->r10s() || _srs_pps_recvmsg_eagain->r10s() || _srs_pps_sendmsg->r10s() || _srs_pps_sendmsg_eagain->r10s() || _srs_pps_sendmmsg->r10s() || _srs_pps_sendmmsg_eagain->r10s()) {
336-
snprintf(buf, sizeof(buf), ", msg=%d,%d,%d,%d,%d,%d", _srs_pps_recvmsg->r10s(), _srs_pps_recvmsg_eagain->r10s(), _srs_pps_sendmsg->r10s(), _srs_pps_sendmsg_eagain->r10s(), _srs_pps_sendmmsg->r10s(), _srs_pps_sendmmsg_eagain->r10s());
330+
if (_srs_pps_recvmsg->r10s() || _srs_pps_recvmsg_eagain->r10s() || _srs_pps_sendmsg->r10s() || _srs_pps_sendmsg_eagain->r10s()) {
331+
snprintf(buf, sizeof(buf), ", msg=%d,%d,%d,%d", _srs_pps_recvmsg->r10s(), _srs_pps_recvmsg_eagain->r10s(), _srs_pps_sendmsg->r10s(), _srs_pps_sendmsg_eagain->r10s());
337332
msg_desc = buf;
338333
}
339334
#endif

trunk/src/protocol/srs_service_st.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,6 @@ int srs_sendmsg(srs_netfd_t stfd, const struct msghdr *msg, int flags, srs_utime
446446
return st_sendmsg((st_netfd_t)stfd, msg, flags, (st_utime_t)timeout);
447447
}
448448

449-
int srs_sendmmsg(srs_netfd_t stfd, struct srs_mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout)
450-
{
451-
return st_sendmmsg((st_netfd_t)stfd, (struct st_mmsghdr*)msgvec, vlen, flags, (st_utime_t)timeout);
452-
}
453-
454449
srs_netfd_t srs_accept(srs_netfd_t stfd, struct sockaddr *addr, int *addrlen, srs_utime_t timeout)
455450
{
456451
return (srs_netfd_t)st_accept((st_netfd_t)stfd, addr, addrlen, (st_utime_t)timeout);

trunk/src/protocol/srs_service_st.hpp

-8
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,6 @@ extern int srs_sendto(srs_netfd_t stfd, void *buf, int len, const struct sockadd
9999
extern int srs_recvmsg(srs_netfd_t stfd, struct msghdr *msg, int flags, srs_utime_t timeout);
100100
extern int srs_sendmsg(srs_netfd_t stfd, const struct msghdr *msg, int flags, srs_utime_t timeout);
101101

102-
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
103-
#include <sys/socket.h>
104-
struct srs_mmsghdr {
105-
struct msghdr msg_hdr; /* Message header */
106-
unsigned int msg_len; /* Number of bytes transmitted */
107-
};
108-
extern int srs_sendmmsg(srs_netfd_t stfd, struct srs_mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout);
109-
110102
extern srs_netfd_t srs_accept(srs_netfd_t stfd, struct sockaddr *addr, int *addrlen, srs_utime_t timeout);
111103

112104
extern ssize_t srs_read(srs_netfd_t stfd, void *buf, size_t nbyte, srs_utime_t timeout);

0 commit comments

Comments
 (0)