Author: hbelusca
Date: Sat Jan 26 16:12:05 2013
New Revision: 58225

URL: http://svn.reactos.org/svn/reactos?rev=58225&view=rev
Log:
[CONSRV]
Fix input/output (read/write) waiter threads notifications. Now console is 
usable.
Go and test it! :D

Modified:
    branches/ros-csrss/win32ss/user/consrv/coninput.c
    branches/ros-csrss/win32ss/user/consrv/console.c
    branches/ros-csrss/win32ss/user/consrv/handle.c

Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/coninput.c?rev=58225&r1=58224&r2=58225&view=diff
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Sat Jan 26 
16:12:05 2013
@@ -93,6 +93,10 @@
                   WaitAny,
                   NULL,
                   NULL);
+    if (!IsListEmpty(&Console->InputBuffer.ReadWaitQueue))
+    {
+        CsrDereferenceWait(&Console->InputBuffer.ReadWaitQueue);
+    }
 
     return STATUS_SUCCESS;
 }
@@ -359,18 +363,6 @@
     DPRINT1("ReadInputBufferThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, 
WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, 
WaitArgument2, WaitFlags);
 
     /*
-     * Somebody is closing a handle to this input buffer,
-     * by calling ConSrvCloseHandleEntry.
-     * See whether we are linked to that handle (ie. we
-     * are a waiter for this handle), and if so, return.
-     */
-    if (InputHandle == InputInfo->HandleEntry)
-    {
-        Status = STATUS_ALERTED;
-        goto Quit;
-    }
-
-    /*
      * If we are notified of the process termination via a call
      * to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
      * CsrDestroyThread, just return.
@@ -378,6 +370,20 @@
     if (WaitFlags & CsrProcessTerminating)
     {
         Status = STATUS_THREAD_IS_TERMINATING;
+        goto Quit;
+    }
+
+    /*
+     * Somebody is closing a handle to this input buffer,
+     * by calling ConSrvCloseHandleEntry.
+     * See whether we are linked to that handle (ie. we
+     * are a waiter for this handle), and if so, return.
+     * Otherwise, ignore the call and continue waiting.
+     */
+    if (InputHandle != NULL)
+    {
+        Status = (InputHandle == InputInfo->HandleEntry ? STATUS_ALERTED
+                                                        : STATUS_PENDING);
         goto Quit;
     }
 
@@ -490,18 +496,6 @@
     DPRINT1("ReadCharsThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, 
WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, 
WaitArgument2, WaitFlags);
 
     /*
-     * Somebody is closing a handle to this input buffer,
-     * by calling ConSrvCloseHandleEntry.
-     * See whether we are linked to that handle (ie. we
-     * are a waiter for this handle), and if so, return.
-     */
-    if (InputHandle == InputInfo->HandleEntry)
-    {
-        Status = STATUS_ALERTED;
-        goto Quit;
-    }
-
-    /*
      * If we are notified of the process termination via a call
      * to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
      * CsrDestroyThread, just return.
@@ -509,6 +503,20 @@
     if (WaitFlags & CsrProcessTerminating)
     {
         Status = STATUS_THREAD_IS_TERMINATING;
+        goto Quit;
+    }
+
+    /*
+     * Somebody is closing a handle to this input buffer,
+     * by calling ConSrvCloseHandleEntry.
+     * See whether we are linked to that handle (ie. we
+     * are a waiter for this handle), and if so, return.
+     * Otherwise, ignore the call and continue waiting.
+     */
+    if (InputHandle != NULL)
+    {
+        Status = (InputHandle == InputInfo->HandleEntry ? STATUS_ALERTED
+                                                        : STATUS_PENDING);
         goto Quit;
     }
 

Modified: branches/ros-csrss/win32ss/user/consrv/console.c
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/console.c?rev=58225&r1=58224&r2=58225&view=diff
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Sat Jan 26 
16:12:05 2013
@@ -15,6 +15,7 @@
 //#define NDEBUG
 #include <debug.h>
 
+
 /* FUNCTIONS *****************************************************************/
 
 BOOL FASTCALL
@@ -87,6 +88,10 @@
                       WaitAll,
                       NULL,
                       NULL);
+        if (!IsListEmpty(&Console->WriteWaitQueue))
+        {
+            CsrDereferenceWait(&Console->WriteWaitQueue);
+        }
     }
 }
 

Modified: branches/ros-csrss/win32ss/user/consrv/handle.c
URL: 
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/handle.c?rev=58225&r1=58224&r2=58225&view=diff
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] Sat Jan 26 
16:12:05 2013
@@ -73,7 +73,11 @@
                           WaitAll,
                           NULL,
                           (PVOID)Entry);
-            // TODO: Dereference the notified waits.
+
+            if (!IsListEmpty(&InputBuffer->ReadWaitQueue))
+            {
+                CsrDereferenceWait(&InputBuffer->ReadWaitQueue);
+            }
         }
 
         /* If the last handle to a screen buffer is closed, delete it... */
@@ -498,8 +502,6 @@
         ConSrvDeleteConsole(Console);
 }
 
-
-
 NTSTATUS
 NTAPI
 ConSrvNewProcess(PCSR_PROCESS SourceProcess,


Reply via email to