mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:13:06 +00:00
-impl. process and thread cleanup
svn path=/trunk/; revision=4847
This commit is contained in:
parent
9b53ffc03a
commit
aba6a902a2
6 changed files with 150 additions and 9 deletions
6
reactos/subsys/win32k/include/cleanup.h
Normal file
6
reactos/subsys/win32k/include/cleanup.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
|
||||||
|
#define _SUBSYS_WIN32K_INCLUDE_CLEANUP_H
|
||||||
|
|
||||||
|
NTSTATUS FASTCALL InitCleanupImpl(VOID);
|
||||||
|
|
||||||
|
#endif /* ndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H */
|
|
@ -2,5 +2,6 @@
|
||||||
#define _SUBSYS_WIN32K_INCLUDE_TIMER_H
|
#define _SUBSYS_WIN32K_INCLUDE_TIMER_H
|
||||||
|
|
||||||
NTSTATUS FASTCALL InitTimerImpl(VOID);
|
NTSTATUS FASTCALL InitTimerImpl(VOID);
|
||||||
|
VOID FASTCALL RemoveTimersThread(HANDLE ThreadID);
|
||||||
|
|
||||||
#endif /* ndef _SUBSYS_WIN32K_INCLUDE_TIMER_H */
|
#endif /* ndef _SUBSYS_WIN32K_INCLUDE_TIMER_H */
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: dllmain.c,v 1.35 2003/05/18 17:16:17 ea Exp $
|
/* $Id: dllmain.c,v 1.36 2003/06/05 22:47:47 gdalsnes Exp $
|
||||||
*
|
*
|
||||||
* Entry Point for win32k.sys
|
* Entry Point for win32k.sys
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
#include <include/input.h>
|
#include <include/input.h>
|
||||||
#include <include/timer.h>
|
#include <include/timer.h>
|
||||||
#include <include/text.h>
|
#include <include/text.h>
|
||||||
|
#include <include/cleanup.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <win32k/debug1.h>
|
#include <win32k/debug1.h>
|
||||||
|
@ -120,6 +121,13 @@ DllMain (
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = InitCleanupImpl();
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint("Failed to initialize cleanup implementation.\n");
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.64 2003/06/03 22:25:53 ekohl Exp $
|
# $Id: makefile,v 1.65 2003/06/05 22:47:47 gdalsnes Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ NTUSER_OBJECTS = ntuser/class.o ntuser/guicheck.o ntuser/hook.o \
|
||||||
ntuser/input.o ntuser/keyboard.o ntuser/callback.o \
|
ntuser/input.o ntuser/keyboard.o ntuser/callback.o \
|
||||||
ntuser/winpos.o ntuser/painting.o ntuser/metric.o \
|
ntuser/winpos.o ntuser/painting.o ntuser/metric.o \
|
||||||
ntuser/windc.o ntuser/prop.o ntuser/scrollbar.o \
|
ntuser/windc.o ntuser/prop.o ntuser/scrollbar.o \
|
||||||
ntuser/timer.o ntuser/misc.o
|
ntuser/timer.o ntuser/misc.o ntuser/cleanup.o
|
||||||
|
|
||||||
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
|
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
|
||||||
objects/color.o objects/coord.o objects/dc.o \
|
objects/color.o objects/coord.o objects/dc.o \
|
||||||
|
|
88
reactos/subsys/win32k/ntuser/cleanup.c
Normal file
88
reactos/subsys/win32k/ntuser/cleanup.c
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* ReactOS W32 Subsystem
|
||||||
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* PURPOSE: Thread/process cleanup
|
||||||
|
* FILE: subsys/win32k/ntuser/cleanup.c
|
||||||
|
* PROGRAMER: Gunnar
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <include/timer.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
W32kCreateProcessNotify(
|
||||||
|
IN HANDLE ParentId,
|
||||||
|
IN HANDLE ProcessId,
|
||||||
|
IN BOOLEAN Create
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Create){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
W32kCreateThreadNotify(
|
||||||
|
IN HANDLE ProcessId,
|
||||||
|
IN HANDLE ThreadId,
|
||||||
|
IN BOOLEAN Create
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Create){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveTimersThread(ThreadId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS FASTCALL
|
||||||
|
InitCleanupImpl()
|
||||||
|
{
|
||||||
|
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = PsSetCreateThreadNotifyRoutine(W32kCreateThreadNotify);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PsSetCreateProcessNotifyRoutine(W32kCreateProcessNotify,
|
||||||
|
FALSE);
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: timer.c,v 1.3 2003/05/22 02:07:22 gdalsnes Exp $
|
/* $Id: timer.c,v 1.4 2003/06/05 22:47:47 gdalsnes Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -69,6 +69,7 @@ typedef struct _MSG_TIMER_ENTRY{
|
||||||
|
|
||||||
|
|
||||||
//return true if the new timer became the first entry
|
//return true if the new timer became the first entry
|
||||||
|
//must hold mutex while calling this
|
||||||
BOOL
|
BOOL
|
||||||
FASTCALL
|
FASTCALL
|
||||||
InsertTimerAscendingOrder(PMSG_TIMER_ENTRY NewTimer)
|
InsertTimerAscendingOrder(PMSG_TIMER_ENTRY NewTimer)
|
||||||
|
@ -101,6 +102,7 @@ InsertTimerAscendingOrder(PMSG_TIMER_ENTRY NewTimer)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//must hold mutex while calling this
|
||||||
PMSG_TIMER_ENTRY
|
PMSG_TIMER_ENTRY
|
||||||
FASTCALL
|
FASTCALL
|
||||||
RemoveTimer(HWND hWnd, UINT_PTR IDEvent, HANDLE ThreadID)
|
RemoveTimer(HWND hWnd, UINT_PTR IDEvent, HANDLE ThreadID)
|
||||||
|
@ -113,20 +115,55 @@ RemoveTimer(HWND hWnd, UINT_PTR IDEvent, HANDLE ThreadID)
|
||||||
while (EnumEntry != &TimerListHead)
|
while (EnumEntry != &TimerListHead)
|
||||||
{
|
{
|
||||||
MsgTimer = CONTAINING_RECORD(EnumEntry, MSG_TIMER_ENTRY, ListEntry);
|
MsgTimer = CONTAINING_RECORD(EnumEntry, MSG_TIMER_ENTRY, ListEntry);
|
||||||
|
EnumEntry = EnumEntry->Flink;
|
||||||
|
|
||||||
if (MsgTimer->Msg.hwnd == hWnd &&
|
if (MsgTimer->Msg.hwnd == hWnd &&
|
||||||
MsgTimer->Msg.wParam == (WPARAM)IDEvent &&
|
MsgTimer->Msg.wParam == (WPARAM)IDEvent &&
|
||||||
MsgTimer->ThreadID == ThreadID)
|
MsgTimer->ThreadID == ThreadID)
|
||||||
{
|
{
|
||||||
RemoveEntryList(EnumEntry);
|
RemoveEntryList(&MsgTimer->ListEntry);
|
||||||
return MsgTimer;
|
return MsgTimer;
|
||||||
}
|
}
|
||||||
EnumEntry = EnumEntry->Flink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: It doesn't kill timers. It just removes them from the list.
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
FASTCALL
|
||||||
|
RemoveTimersThread(HANDLE ThreadID)
|
||||||
|
{
|
||||||
|
PMSG_TIMER_ENTRY MsgTimer;
|
||||||
|
PLIST_ENTRY EnumEntry;
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&Mutex);
|
||||||
|
|
||||||
|
EnumEntry = TimerListHead.Flink;
|
||||||
|
while (EnumEntry != &TimerListHead)
|
||||||
|
{
|
||||||
|
MsgTimer = CONTAINING_RECORD(EnumEntry, MSG_TIMER_ENTRY, ListEntry);
|
||||||
|
EnumEntry = EnumEntry->Flink;
|
||||||
|
|
||||||
|
if (MsgTimer->ThreadID == ThreadID)
|
||||||
|
{
|
||||||
|
if (MsgTimer->Msg.hwnd == NULL)
|
||||||
|
{
|
||||||
|
RtlClearBits(&HandleLessTimersBitMap, ((UINT_PTR)MsgTimer->Msg.wParam) - 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveEntryList(&MsgTimer->ListEntry);
|
||||||
|
ExFreePool(MsgTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExReleaseFastMutex(&Mutex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -163,6 +200,7 @@ NtUserSetTimer(
|
||||||
Index = RtlFindClearBitsAndSet(&HandleLessTimersBitMap, 1, HintIndex);
|
Index = RtlFindClearBitsAndSet(&HandleLessTimersBitMap, 1, HintIndex);
|
||||||
if (Index == -1)
|
if (Index == -1)
|
||||||
{
|
{
|
||||||
|
ExReleaseFastMutex(&Mutex);
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +304,9 @@ NtUserSetSystemTimer(
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS STDCALL
|
static NTSTATUS STDCALL
|
||||||
TimerThreadMain(VOID)
|
TimerThreadMain(
|
||||||
|
PVOID StartContext
|
||||||
|
)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
LARGE_INTEGER CurrentTime;
|
LARGE_INTEGER CurrentTime;
|
||||||
|
@ -305,12 +345,10 @@ TimerThreadMain(VOID)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: 1) Find a faster way of getting the thread message queue? (lookup by id is slow)
|
* FIXME: 1) Find a faster way of getting the thread message queue? (lookup by id is slow)
|
||||||
* 2) Kill all timers for thread when the thread exits?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!NT_SUCCESS(PsLookupThreadByThreadId(MsgTimer->ThreadID, &Thread)))
|
if (!NT_SUCCESS(PsLookupThreadByThreadId(MsgTimer->ThreadID, &Thread)))
|
||||||
{
|
{
|
||||||
//FIXME: remove all other timers for this thread also?
|
|
||||||
ExFreePool(MsgTimer);
|
ExFreePool(MsgTimer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue