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

ST: Support thread-local for multiple threads.

1. All statick and global variables is thread-local.
2. Call st_init() to init st for each thread.
3. Notice that ST is isolate for threads.
This commit is contained in:
winlin 2021-04-05 12:37:53 +08:00
parent d117145b95
commit 339d3b31cc
8 changed files with 61 additions and 54 deletions

View file

@ -51,10 +51,10 @@
// Global stat.
#if defined(DEBUG) && defined(DEBUG_STATS)
unsigned long long _st_stat_epoll = 0;
unsigned long long _st_stat_epoll_zero = 0;
unsigned long long _st_stat_epoll_shake = 0;
unsigned long long _st_stat_epoll_spin = 0;
__thread unsigned long long _st_stat_epoll = 0;
__thread unsigned long long _st_stat_epoll_zero = 0;
__thread unsigned long long _st_stat_epoll_shake = 0;
__thread unsigned long long _st_stat_epoll_spin = 0;
#endif
#if !defined(MD_HAVE_KQUEUE) && !defined(MD_HAVE_EPOLL) && !defined(MD_HAVE_SELECT)
@ -86,7 +86,7 @@ typedef struct _kq_fd_data {
int revents;
} _kq_fd_data_t;
static struct _st_kqdata {
static __thread struct _st_kqdata {
_kq_fd_data_t *fd_data;
struct kevent *evtlist;
struct kevent *addlist;
@ -119,7 +119,7 @@ typedef struct _epoll_fd_data {
int revents;
} _epoll_fd_data_t;
static struct _st_epolldata {
static __thread struct _st_epolldata {
_epoll_fd_data_t *fd_data;
struct epoll_event *evtlist;
int fd_data_size;
@ -147,7 +147,7 @@ static struct _st_epolldata {
#endif /* MD_HAVE_EPOLL */
_st_eventsys_t *_st_eventsys = NULL;
__thread _st_eventsys_t *_st_eventsys = NULL;
#ifdef MD_HAVE_SELECT