https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc710885d0ea5801fc16bcdc4aab9b83bdb25a80

commit cc710885d0ea5801fc16bcdc4aab9b83bdb25a80
Author:     Giannis Adamopoulos <[email protected]>
AuthorDate: Thu Jan 3 14:20:22 2019 +0200
Commit:     Giannis Adamopoulos <[email protected]>
CommitDate: Fri Jan 4 13:29:26 2019 +0200

    [WINSRV] usersrv: remove wrong dead code and fix indentation
---
 win32ss/user/winsrv/usersrv/shutdown.c | 179 +++++++++++++--------------------
 1 file changed, 72 insertions(+), 107 deletions(-)

diff --git a/win32ss/user/winsrv/usersrv/shutdown.c 
b/win32ss/user/winsrv/usersrv/shutdown.c
index 539ef2a932..71ab8c9fab 100644
--- a/win32ss/user/winsrv/usersrv/shutdown.c
+++ b/win32ss/user/winsrv/usersrv/shutdown.c
@@ -394,31 +394,6 @@ IsConsoleMode(VOID)
     return (BOOLEAN)NtUserCallNoParam(NOPARAM_ROUTINE_ISCONSOLEMODE);
 }
 
-
-/* TODO: Find an other way to do it. */
-#if 0
-VOID FASTCALL
-ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData, DWORD 
Timeout)
-{
-    HANDLE Thread;
-
-    DPRINT("ConioConsoleCtrlEvent Parent ProcessId = %x\n", 
ProcessData->ClientId.UniqueProcess);
-
-    if (ProcessData->CtrlDispatcher)
-    {
-        Thread = CreateRemoteThread(ProcessData->ProcessHandle, NULL, 0,
-                                    (LPTHREAD_START_ROUTINE) 
ProcessData->CtrlDispatcher,
-                                    UlongToPtr(Event), 0, NULL);
-        if (Thread == NULL)
-        {
-            DPRINT1("Failed thread creation (Error: 0x%x)\n", GetLastError());
-            return;
-        }
-        WaitForSingleObject(Thread, Timeout);
-        CloseHandle(Thread);
-    }
-}
-#endif
 /************************************************/
 
 
@@ -448,8 +423,10 @@ ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
         }
         if (TopWnd != tmpWnd) MY_DPRINT("(TopWnd = %x) != (tmpWnd = %x)\n", 
TopWnd, tmpWnd);
     }
-    if (TopWnd == NULL)
+    else
+    {
         return;
+    }
 
     Context->wParam = Flags2;
     Context->lParam = (0 != (Flags & EWX_CALLER_WINLOGON_LOGOFF) ?
@@ -511,116 +488,104 @@ NotifyProcessForShutdown(PCSR_PROCESS CsrProcess,
                          UINT Flags)
 {
     DWORD QueryResult = QUERY_RESULT_CONTINUE;
+    PCSR_PROCESS Process;
+    PCSR_THREAD Thread;
+    PLIST_ENTRY NextEntry;
+    NOTIFY_CONTEXT Context;
 
     /* In case we make a forced shutdown, just kill the process */
     if (Flags & EWX_FORCE)
         return TRUE;
 
-    // TODO: Find an other way whether or not the process has a console.
-#if 0
-    if (CsrProcess->Console)
-    {
-        ConioConsoleCtrlEventTimeout(CTRL_LOGOFF_EVENT, CsrProcess,
-                                     ShutdownSettings->WaitToKillAppTimeout);
-    }
-    else
-#endif
-    {
-        PCSR_PROCESS Process;
-        PCSR_THREAD Thread;
-        PLIST_ENTRY NextEntry;
+    Context.ShutdownSettings = ShutdownSettings;
+    Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown by 
default.
 
-        NOTIFY_CONTEXT Context;
-        Context.ShutdownSettings = ShutdownSettings;
-        Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown 
by default.
+    /* Lock the process */
+    CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
 
-        /* Lock the process */
-        CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
+    /* Send first the QUERYENDSESSION messages to all the threads of the 
process */
+    MY_DPRINT2("Sending the QUERYENDSESSION messages...\n");
 
-        /* Send first the QUERYENDSESSION messages to all the threads of the 
process */
-        MY_DPRINT2("Sending the QUERYENDSESSION messages...\n");
-
-        NextEntry = CsrProcess->ThreadList.Flink;
-        while (NextEntry != &CsrProcess->ThreadList)
-        {
-            /* Get the current thread entry */
-            Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
+    NextEntry = CsrProcess->ThreadList.Flink;
+    while (NextEntry != &CsrProcess->ThreadList)
+    {
+        /* Get the current thread entry */
+        Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
 
-            /* Move to the next entry */
-            NextEntry = NextEntry->Flink;
+        /* Move to the next entry */
+        NextEntry = NextEntry->Flink;
 
-            /* If the thread is being terminated, just skip it */
-            if (Thread->Flags & CsrThreadTerminated) continue;
+        /* If the thread is being terminated, just skip it */
+        if (Thread->Flags & CsrThreadTerminated) continue;
 
-            /* Reference the thread and temporarily unlock the process */
-            CsrReferenceThread(Thread);
-            CsrUnlockProcess(Process);
+        /* Reference the thread and temporarily unlock the process */
+        CsrReferenceThread(Thread);
+        CsrUnlockProcess(Process);
 
-            Context.QueryResult = QUERY_RESULT_CONTINUE;
-            ThreadShutdownNotify(Thread, Flags,
-                                 MCS_QUERYENDSESSION,
-                                 &Context);
+        Context.QueryResult = QUERY_RESULT_CONTINUE;
+        ThreadShutdownNotify(Thread, Flags,
+                             MCS_QUERYENDSESSION,
+                             &Context);
 
-            /* Lock the process again and dereference the thread */
-            CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, 
&Process);
-            CsrDereferenceThread(Thread);
+        /* Lock the process again and dereference the thread */
+        CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
+        CsrDereferenceThread(Thread);
 
-            // FIXME: Analyze Context.QueryResult !!
-            /**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
-        }
+        // FIXME: Analyze Context.QueryResult !!
+        /**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
+    }
 
-        QueryResult = Context.QueryResult;
-        MY_DPRINT2("QueryResult = %s\n",
-                   QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
+    QueryResult = Context.QueryResult;
+    MY_DPRINT2("QueryResult = %s\n",
+               QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
 
-        /* Now send the ENDSESSION messages to the threads */
-        MY_DPRINT2("Now sending the ENDSESSION messages...\n");
+    /* Now send the ENDSESSION messages to the threads */
+    MY_DPRINT2("Now sending the ENDSESSION messages...\n");
 
-        NextEntry = CsrProcess->ThreadList.Flink;
-        while (NextEntry != &CsrProcess->ThreadList)
-        {
-            /* Get the current thread entry */
-            Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
+    NextEntry = CsrProcess->ThreadList.Flink;
+    while (NextEntry != &CsrProcess->ThreadList)
+    {
+        /* Get the current thread entry */
+        Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
 
-            /* Move to the next entry */
-            NextEntry = NextEntry->Flink;
+        /* Move to the next entry */
+        NextEntry = NextEntry->Flink;
 
-            /* If the thread is being terminated, just skip it */
-            if (Thread->Flags & CsrThreadTerminated) continue;
+        /* If the thread is being terminated, just skip it */
+        if (Thread->Flags & CsrThreadTerminated) continue;
 
-            /* Reference the thread and temporarily unlock the process */
-            CsrReferenceThread(Thread);
-            CsrUnlockProcess(Process);
+        /* Reference the thread and temporarily unlock the process */
+        CsrReferenceThread(Thread);
+        CsrUnlockProcess(Process);
 
-            Context.QueryResult = QUERY_RESULT_CONTINUE;
-            ThreadShutdownNotify(Thread, Flags,
-                                 (QUERY_RESULT_ABORT != QueryResult) ? 
MCS_ENDSESSION : 0,
-                                 &Context);
+        Context.QueryResult = QUERY_RESULT_CONTINUE;
+        ThreadShutdownNotify(Thread, Flags,
+                             (QUERY_RESULT_ABORT != QueryResult) ? 
MCS_ENDSESSION : 0,
+                             &Context);
 
-            /* Lock the process again and dereference the thread */
-            CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, 
&Process);
-            CsrDereferenceThread(Thread);
-        }
+        /* Lock the process again and dereference the thread */
+        CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
+        CsrDereferenceThread(Thread);
+    }
 
 Quit:
-        /* Unlock the process */
-        CsrUnlockProcess(Process);
+    /* Unlock the process */
+    CsrUnlockProcess(Process);
 
 #if 0
-        if (Context.UIThread)
+    if (Context.UIThread)
+    {
+        if (Context.Dlg)
         {
-            if (Context.Dlg)
-            {
-                SendMessageW(Context.Dlg, WM_CLOSE, 0, 0);
-            }
-            else
-            {
-                TerminateThread(Context.UIThread, QUERY_RESULT_ERROR);
-            }
-            CloseHandle(Context.UIThread);
+            SendMessageW(Context.Dlg, WM_CLOSE, 0, 0);
         }
-#endif
+        else
+        {
+            TerminateThread(Context.UIThread, QUERY_RESULT_ERROR);
+        }
+        CloseHandle(Context.UIThread);
     }
+#endif
 
     /* Kill the process unless we abort shutdown */
     return (QueryResult != QUERY_RESULT_ABORT);

Reply via email to