diff options
author | dzwdz | 2022-05-04 14:12:50 +0200 |
---|---|---|
committer | dzwdz | 2022-05-04 14:12:50 +0200 |
commit | 82f2c02510043927e73926ce52ab4b813e7bc40c (patch) | |
tree | 86162560e5198c8c006c4914e4cafda2623f01cc /src | |
parent | 3bf07641ee5ba1c6ec56b81a7f34abe1267d3ac1 (diff) |
kernel/proc: leave the vfs_request when killing a WAITS4FS proc
...instead of letting the hwole process stay around.
This could end up a bit more complex, I have no idea how to test killing
processes during vfs requests.
The upside of this is that I can remove all the deathbed/deadparent
weirdness now.
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/proc.c | 20 | ||||
-rw-r--r-- | src/kernel/vfs/request.c | 27 |
2 files changed, 22 insertions, 25 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index 40399d8..0e79c93 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -298,6 +298,7 @@ void process_kill(struct process *p, int ret) { process_kill(c, -1); } + struct vfs_request *req; switch (p->state) { case PS_RUNNING: case PS_WAITS4CHILDDEATH: @@ -307,20 +308,11 @@ void process_kill(struct process *p, int ret) { case PS_WAITS4FS: // if the request wasn't accepted we could just remove this process from the queue case PS_WAITS4IRQ: - /* instead of killing the process outright, we mark it to get killed - * as soon as it becomes running and we try to give it control. - * - * we also reparent it to process_deadparent because we don't want - * dead processes to have any alive children */ - /* TODO: because requests are no longer owned by the parent, we can safely kill it. - * this whole deathbed thing (and, by extension, freeing after killing) is unnecessary */ - // TODO process_reparent? - p->deathbed = true; - process_forget(p); - p->sibling = process_deadparent->child; - p->parent = process_deadparent; - process_deadparent->child = p; - return; + req = p->state == PS_WAITS4FS + ? p->waits4fs.req : p->waits4irq.req; + req->caller = NULL; + // TODO test this + break; case PS_DEAD: case PS_DEADER: diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index edb1fce..7c1861d 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -83,17 +83,22 @@ int vfs_request_finish(struct vfs_request *req, int ret) { // open() calls need special handling // we need to wrap the id returned by the VFS in a handle passed to // the client - assert(req->caller); - handle_t handle = process_find_handle(req->caller, 0); - if (handle < 0) - panic_invalid_state(); // we check for free handles before the open() call - - struct handle *backing = handle_init(HANDLE_FILE); - backing->file.backend = req->backend; - req->backend->refcount++; - backing->file.id = ret; - req->caller->handles[handle] = backing; - ret = handle; + if (req->caller) { + handle_t handle = process_find_handle(req->caller, 0); + if (handle < 0) + panic_invalid_state(); // we check for free handles before the open() call + + struct handle *backing = handle_init(HANDLE_FILE); + backing->file.backend = req->backend; + req->backend->refcount++; + backing->file.id = ret; + req->caller->handles[handle] = backing; + ret = handle; + } else { + // caller got killed + // TODO write tests & implement + panic_unimplemented(); + } } if (req->input.kern) |