Skip to content

Commit

Permalink
ST: For #2188: Remove sendmmsg from ST.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 25, 2021
1 parent aaeb891 commit f4872e5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 77 deletions.
4 changes: 0 additions & 4 deletions trunk/3rdparty/st-srs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,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
Expand Down
65 changes: 0 additions & 65 deletions trunk/3rdparty/st-srs/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -726,69 +724,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.
Expand Down
8 changes: 0 additions & 8 deletions trunk/3rdparty/st-srs/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,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
Expand Down
2 changes: 2 additions & 0 deletions trunk/research/msg_zerocopy/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ int main(int argc, char** argv)
memcpy(&p->msg_hdr, &msg, sizeof(msghdr));
p->msg_len = 0;
}

// The sendmmsg is removed by https://github.com/ossrs/srs/commit/34dae0fe0ddf2e95353ca8cbdc799f4abf96aead
if (zerocopy) {
r0 = st_sendmmsg(stfd, hdrs, nn_copies + 1, MSG_ZEROCOPY, ST_UTIME_NO_TIMEOUT);
} else {
Expand Down

0 comments on commit f4872e5

Please sign in to comment.