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

For #906, #902, use coroutine for reusable thread

This commit is contained in:
winlin 2017-05-29 20:33:32 +08:00
parent 2ed2513f08
commit ea9a5f26d9
18 changed files with 174 additions and 274 deletions

View file

@ -23,6 +23,8 @@
#include <srs_service_st.hpp>
#include <fcntl.h>
#include <sys/socket.h>
using namespace std;
#include <srs_kernel_error.hpp>
@ -88,6 +90,19 @@ void srs_close_stfd(st_netfd_t& stfd)
}
}
void srs_fd_close_exec(int fd)
{
int flags = fcntl(fd, F_GETFD);
flags |= FD_CLOEXEC;
fcntl(fd, F_SETFD, flags);
}
void srs_socket_reuse_addr(int fd)
{
int v = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(int));
}
SrsStSocket::SrsStSocket()
{
stfd = NULL;