Add missing cleanup code in Process_Destroy
This commit is contained in:
parent
220328dd91
commit
4e4490872e
@ -80,6 +80,7 @@ typedef struct Process {
|
||||
|
||||
// General
|
||||
void Thread_Init();
|
||||
void Thread_InitAP();
|
||||
|
||||
// Process functions
|
||||
Process *Process_Create(Process *parent, const char *title);
|
||||
@ -117,6 +118,7 @@ void Thread_SwitchArch(Thread *oldthr, Thread *newthr);
|
||||
|
||||
// Handle Functions
|
||||
void Handle_Init(Process *proc);
|
||||
void Handle_Destroy(Process *proc);
|
||||
uint64_t Handle_Add(Process *proc, Handle *handle);
|
||||
void Handle_Remove(Process *proc, Handle *handle);
|
||||
Handle *Handle_Lookup(Process *proc, uint64_t fd);
|
||||
|
@ -29,6 +29,20 @@ Handle_Init(Process *proc)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Handle_Destroy(Process *proc)
|
||||
{
|
||||
int i;
|
||||
Handle *handle;
|
||||
|
||||
for (i = 0; i < PROCESS_HANDLE_SLOTS; i++) {
|
||||
TAILQ_FOREACH(handle, &proc->handles[i], handleList) {
|
||||
(handle->close)(handle);
|
||||
TAILQ_REMOVE(&proc->handles[i], handle, handleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Handle_Add(Process *proc, Handle *handle)
|
||||
{
|
||||
|
@ -136,8 +136,11 @@ Process_Create(Process *parent, const char *title)
|
||||
static void
|
||||
Process_Destroy(Process *proc)
|
||||
{
|
||||
Handle_Destroy(proc);
|
||||
|
||||
Spinlock_Destroy(&proc->lock);
|
||||
Semaphore_Destroy(&proc->zombieSemaphore);
|
||||
Semaphore_Destroy(&proc->zombieProcSemaphore);
|
||||
PMap_DestroyAS(proc->space);
|
||||
|
||||
// XXX: Close and destroy handles
|
||||
@ -341,8 +344,10 @@ Thread_Destroy(Thread *thr)
|
||||
|
||||
// Free userspace stack
|
||||
|
||||
Spinlock_Lock(&proc->lock);
|
||||
proc->threads--;
|
||||
TAILQ_REMOVE(&proc->threadList, thr, threadList);
|
||||
Spinlock_Unlock(&proc->lock);
|
||||
|
||||
// Free AS
|
||||
PAlloc_Release((void *)thr->kstack);
|
||||
|
Loading…
x
Reference in New Issue
Block a user