mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 13:29:48 +01:00
core: Fix unlock sync (#119)
* core: error on repeated unlock * core: change termination points This seems to fix sporadic freezes when unlocking.
This commit is contained in:
parent
fa2a875e33
commit
4286cfb29c
1 changed files with 8 additions and 9 deletions
|
@ -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;
|
||||
|
@ -352,7 +349,7 @@ void CHyprlock::run() {
|
|||
});
|
||||
|
||||
std::thread timersThr([this]() {
|
||||
while (1) {
|
||||
while (!m_bTerminate) {
|
||||
// calc nearest thing
|
||||
m_sLoopState.timersMutex.lock();
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue