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:
parent
d117145b95
commit
339d3b31cc
8 changed files with 61 additions and 54 deletions
14
trunk/3rdparty/st-srs/event.c
vendored
14
trunk/3rdparty/st-srs/event.c
vendored
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue