Skip to content

Commit

Permalink
修复多线程模式下tk->io_sentry_会失效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyangzi committed May 20, 2016
1 parent 797b97c commit 6f5680e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions libgo/linux/io_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ void IoWait::CoSwitch()

void IoWait::SchedulerSwitch(Task* tk)
{
wait_io_sentries_.push(tk->io_sentry_.get()); // A
if (tk->io_sentry_->io_state_ == IoSentry::triggered) // B
__IOBlockTriggered(tk->io_sentry_);
auto sentry = tk->io_sentry_; // reference increment. avoid wakeup task at other thread.
wait_io_sentries_.push(sentry.get()); // A
if (sentry->io_state_ == IoSentry::triggered) // B
__IOBlockTriggered(sentry);
}

void IoWait::IOBlockTriggered(IoSentryPtr io_sentry)
Expand Down Expand Up @@ -197,7 +198,8 @@ void IoWait::CreateEpoll()

void IoWait::IgnoreSigPipe()
{
signal(SIGPIPE, SIG_IGN);
DebugPrint(dbg_ioblock, "Ignore signal SIGPIPE");
sigignore(SIGPIPE);
}

bool IoWait::IsEpollCreated()
Expand Down
2 changes: 1 addition & 1 deletion samples/sample9_curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char** argv)
exit(1);
}

// co_sched.GetOptions().debug = co::dbg_scheduler | co::dbg_ioblock | co::dbg_hook;
// co_sched.GetOptions().debug = co::dbg_ioblock;
// co_sched.GetOptions().debug_output = fopen("log", "w+");
// co_sched.GetOptions().enable_work_steal = false;

Expand Down

0 comments on commit 6f5680e

Please sign in to comment.