Skip to content

Commit

Permalink
thor: Don't launch gdbserver more than once if servers die
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke committed Oct 17, 2023
1 parent 4beda35 commit ef19f00
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions kernel/thor/generic/gdbserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,24 +440,29 @@ coroutine<frg::expected<ProtocolError>> GdbServer::handleRequest_() {

} // anonymous namespace

static bool launched = false;

void launchGdbServer(smarter::shared_ptr<Thread, ActiveHandle> thread,
frg::string_view path, smarter::shared_ptr<WorkQueue> wq) {
auto channel = solicitIoChannel("kernel-gdbserver");
if(!channel) {
infoLogger() << "thor: No I/O channel available for gdbserver" << frg::endlog;
return;
if(!launched) {
launched = true;
auto channel = solicitIoChannel("kernel-gdbserver");
if(!channel) {
infoLogger() << "thor: No I/O channel available for gdbserver" << frg::endlog;
return;
}
infoLogger() << "thor: Launching gdbserver on I/O channel "
<< channel->descriptiveTag() << frg::endlog;

auto svr = frg::construct<GdbServer>(*kernelAlloc,
std::move(thread), path, std::move(channel), std::move(wq));
async::detach_with_allocator(*kernelAlloc,
async::transform(svr->run(), [] (auto outcome) {
if(!outcome)
infoLogger() << "thor: Internal error in gdbserver" << frg::endlog;
})
);
}
infoLogger() << "thor: Launching gdbserver on I/O channel "
<< channel->descriptiveTag() << frg::endlog;

auto svr = frg::construct<GdbServer>(*kernelAlloc,
std::move(thread), path, std::move(channel), std::move(wq));
async::detach_with_allocator(*kernelAlloc,
async::transform(svr->run(), [] (auto outcome) {
if(!outcome)
infoLogger() << "thor: Internal error in gdbserver" << frg::endlog;
})
);
}

} // namespace thor

0 comments on commit ef19f00

Please sign in to comment.