Explorar o código

Kernel: Fix sys$select() not marking fd's after blocking was avoided

In case multiple file descriptors in the `fd_set` were already readable
and/or writable when calling Thread::block<SelectBlocker>(), we would
only mark the first fd in the output sets instead of all relevant fd's.

The short-circuit code path when blocking isn't necessary must ensure
that unblock flags are collected for all file descriptors, not just the
first one encountered.

Fixes #5795.
Andreas Kling %!s(int64=4) %!d(string=hai) anos
pai
achega
a7b5a58509
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      Kernel/ThreadBlockers.cpp

+ 1 - 1
Kernel/ThreadBlockers.cpp

@@ -385,7 +385,7 @@ void Thread::SelectBlocker::not_blocking(bool timeout_in_past)
     // Either the timeout was in the past or we didn't add all blockers
     // Either the timeout was in the past or we didn't add all blockers
     VERIFY(timeout_in_past || !m_should_block);
     VERIFY(timeout_in_past || !m_should_block);
     ScopedSpinLock lock(m_lock);
     ScopedSpinLock lock(m_lock);
-    if (!m_did_unblock) {
+    if (!m_should_block || !m_did_unblock) {
         m_did_unblock = true;
         m_did_unblock = true;
         if (!timeout_in_past) {
         if (!timeout_in_past) {
             auto count = collect_unblocked_flags();
             auto count = collect_unblocked_flags();