Skip to content

Commit

Permalink
Merge #375
Browse files Browse the repository at this point in the history
375: Retry loop for DRM master r=RAOF a=AlanGriffiths

Retry drmSetMaster() a few times and if it doesn't work die. (Fixes #373)

Co-authored-by: Alan Griffiths <alan@octopull.co.uk>
  • Loading branch information
bors[bot] and AlanGriffiths committed May 22, 2018
2 parents a48c930 + f2d907e commit a18a602
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/server/display_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#include "mir/log.h"
#include "mir/unwind_helpers.h"

#include <boost/exception/diagnostic_information.hpp>

#include <chrono>
#include <stdexcept>
#include <thread>

namespace mc = mir::compositor;
namespace mf = mir::frontend;
Expand Down Expand Up @@ -117,7 +121,24 @@ struct mir::DisplayServer::Private
try
{
auto disp = try_but_revert_if_unwinding(
[this] { display->resume(); },
[this]
{
auto const deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds{500};

retry:
try
{
display->resume();
}
catch(std::runtime_error const& e)
{
if (std::chrono::steady_clock::now() > deadline)
fatal_error(("Failed to resume display:\n" + boost::diagnostic_information(e)).c_str());

std::this_thread::sleep_for(std::chrono::milliseconds{50});
goto retry;
}
},
[&, this] { display->pause(); });

auto comp = try_but_revert_if_unwinding(
Expand Down

0 comments on commit a18a602

Please sign in to comment.