You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We create EventLoopThread and initialize it in father process, but we use it in child process.
If we have only one child process , everything goes well.
But if we have multi child processes, something goes wrong.
Because EventLoop::watcher_ is created and initialized in father process, all children processes inherited father's pipe. When we use the pipe to do a notification in one child process, the notification may be received by another child process randomly.
if it's message had readed by other process
we marked watcher had been notified_ and never notify it again
if (!notified_.load()) {
DLOG_TRACE << "call watcher_->Nofity() notified_.store(true)";
// We must set notified_ to true before calling `watcher_->Nodify()`// otherwise there is a change that:// 1. We called watcher_- > Nodify() on thread1// 2. On thread2 we watched this event, so wakeup the CPU changed to run this EventLoop on thread2 and executed all the pending task// 3. Then the CPU changed to run on thread1 and set notified_ to true// 4. Then, some thread except thread2 call this QueueInLoop to push a task into the queue, and find notified_ is true, so there is no change to wakeup thread2 to execute this task
notified_.store(true);
// Sometimes one thread invoke EventLoop::QueueInLoop(...), but anther// thread is invoking EventLoop::Stop() to stop this loop. At this moment// this loop maybe is stopping and the watcher_ object maybe has been// released already.if (watcher_) {
watcher_->Notify();
} else {
DLOG_TRACE << "status=" << StatusToString();
assert(!IsRunning());
}
} else {
DLOG_TRACE << "No need to call watcher_->Nofity()";
}
The text was updated successfully, but these errors were encountered:
We create EventLoopThread and initialize it in father process, but we use it in child process.
If we have only one child process , everything goes well.
But if we have multi child processes, something goes wrong.
Because EventLoop::watcher_ is created and initialized in father process, all children processes inherited father's pipe. When we use the pipe to do a notification in one child process, the notification may be received by another child process randomly.
if it's message had readed by other process
we marked watcher had been notified_ and never notify it again
The text was updated successfully, but these errors were encountered: