Skip to content

Commit

Permalink
r35334: Fix epoll thread duplicated start
Browse files Browse the repository at this point in the history
  • Loading branch information
gejun committed Sep 29, 2017
1 parent b9442c2 commit c52b0fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bthread/fd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ class EpollThread {
if (started()) {
return -1;
}
_start_mutex.lock();
// Double check
if (started()) {
_start_mutex.unlock();
return -1;
}
_epfd = epoll_create(epoll_size);
_start_mutex.unlock();
if (_epfd < 0) {
PLOG(FATAL) << "Fail to epoll_create";
return -1;
Expand Down Expand Up @@ -334,6 +341,7 @@ class EpollThread {
int _epfd;
bool _stop;
bthread_t _tid;
butil::Mutex _start_mutex;
};

EpollThread epoll_thread[BTHREAD_EPOLL_THREAD_NUM];
Expand Down

0 comments on commit c52b0fd

Please sign in to comment.