Skip to content

Commit

Permalink
Fix DebugServer sequence check (#4326)
Browse files Browse the repository at this point in the history
b/369965331

Fixes error "FATAL:sequenced_task_runner.cc(113)] Check failed:
current_default_handle. Error: This caller requires a sequenced context
(i.e. the current task needs to run from a SequencedTaskRunner)"

During the update of base, net and dependencies, there was a mass
replacement of uses of SingleThreadedTaskRunner with
SequencedTaskRunner. As part of that cleanup, we removed uses of
base::MessageLoop::current() with calls to
 base::SequencedTaskRunner::GetDefault().

In this particular case for DebugServer, it uses a base::Thread directly
rather than a SingleThreadedTaskRunner, so we can't compare our
thread.task_runner() with
base::SequencedTaskRunner::GetCurrentDefault(), but instead should use
task_runner()->RunsTasksInCurrentSequence() (as mentioned in Jelle's
comments in #2521)
  • Loading branch information
sideb0ard authored Oct 29, 2024
1 parent 84a595e commit f477ac7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cobalt/debug/remote/debug_web_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ void DebugWebServer::OnDebugClientEvent(const std::string& method,

// Debugger events occur on the thread of the web module the debugger is
// attached to, so we must post to the server thread here.
if (base::SequencedTaskRunner::GetCurrentDefault() !=
http_server_thread_.task_runner()) {
if (!http_server_thread_.task_runner()->RunsTasksInCurrentSequence()) {
http_server_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&DebugWebServer::OnDebugClientEvent,
base::Unretained(this), method, json_params));
Expand All @@ -286,8 +285,7 @@ void DebugWebServer::OnDebugClientEvent(const std::string& method,
void DebugWebServer::OnDebugClientDetach(const std::string& reason) {
// Debugger events occur on the thread of the web module the debugger is
// attached to, so we must post to the server thread here.
if (base::SequencedTaskRunner::GetCurrentDefault() !=
http_server_thread_.task_runner()) {
if (!http_server_thread_.task_runner()->RunsTasksInCurrentSequence()) {
http_server_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&DebugWebServer::OnDebugClientDetach,
base::Unretained(this), reason));
Expand Down

0 comments on commit f477ac7

Please sign in to comment.