Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unlock sync #119

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/core/hyprlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,9 @@ void CHyprlock::run() {
};

std::thread pollThr([this, &pollfds]() {
while (1) {
while (!m_bTerminate) {
int ret = poll(pollfds, 1, 5000 /* 5 seconds, reasonable. It's because we might need to terminate */);

if (m_bTerminate)
break;

if (ret < 0) {
Debug::log(CRIT, "[core] Polling fds failed with {}", errno);
m_bTerminate = true;
Expand All @@ -352,7 +349,7 @@ void CHyprlock::run() {
});

std::thread timersThr([this]() {
while (1) {
while (!m_bTerminate) {
// calc nearest thing
m_sLoopState.timersMutex.lock();

Expand All @@ -369,9 +366,6 @@ void CHyprlock::run() {
m_sLoopState.timerCV.wait_for(lk, std::chrono::milliseconds((int)least + 1), [this] { return m_sLoopState.timerEvent; });
m_sLoopState.timerEvent = false;

if (m_bTerminate)
break;

// notify main
std::lock_guard<std::mutex> lg2(m_sLoopState.eventLoopMutex);
Debug::log(TRACE, "timer thread firing");
Expand Down Expand Up @@ -410,7 +404,7 @@ void CHyprlock::run() {
do {
ret = wl_display_dispatch_pending(m_sWaylandState.display);
wl_display_flush(m_sWaylandState.display);
} while (ret > 0);
} while (ret > 0 && !m_bTerminate);

// do timers
m_sLoopState.timersMutex.lock();
Expand Down Expand Up @@ -717,6 +711,11 @@ void CHyprlock::lockSession() {

void CHyprlock::unlockSession() {
Debug::log(LOG, "Unlocking session");
if (m_bTerminate && !m_sLockState.lock) {
Debug::log(ERR, "Unlock already happend?");
return;
}

ext_session_lock_v1_unlock_and_destroy(m_sLockState.lock);
m_sLockState.lock = nullptr;

Expand Down
Loading