From 28f42fceccd4095b07f0df67647c8b0ad606b5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 12 Mar 2004 05:28:50 +0000 Subject: [PATCH] get_port_info() is not supposed to succeed on a closed port. Saved the port_entry.closed member and now set the capacity to 0, since it is not used any longer (reduces the size of the port table). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6956 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/port.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/kernel/core/port.c b/src/kernel/core/port.c index 0f72f7021f..51d5a78fc1 100644 --- a/src/kernel/core/port.c +++ b/src/kernel/core/port.c @@ -46,7 +46,6 @@ struct port_entry { sem_id write_sem; int32 total_count; struct list msg_queue; - bool closed; }; // internal API @@ -476,7 +475,7 @@ close_port(port_id id) } // mark port to disable writing - sPorts[slot].closed = true; + sPorts[slot].capacity = 0; RELEASE_PORT_LOCK(sPorts[slot]); restore_interrupts(state); @@ -611,10 +610,10 @@ _get_port_info(port_id id, port_info *info, size_t size) state = disable_interrupts(); GRAB_PORT_LOCK(sPorts[slot]); - if (sPorts[slot].id != id) { + if (sPorts[slot].id != id || sPorts[slot].capacity == 0) { RELEASE_PORT_LOCK(sPorts[slot]); restore_interrupts(state); - dprintf("get_port_info: invalid port_id %ld\n", id); + TRACE(("get_port_info: invalid port_id %ld\n", id)); return B_BAD_PORT_ID; } @@ -654,7 +653,7 @@ _get_next_port_info(team_id team, int32 *_cookie, struct port_info *info, size_t while (slot < gMaxPorts) { GRAB_PORT_LOCK(sPorts[slot]); - if (sPorts[slot].id != -1 && sPorts[slot].owner == team) { + if (sPorts[slot].id != -1 && sPorts[slot].capacity != 0 && sPorts[slot].owner == team) { // found one! fill_port_info(&sPorts[slot], info, size); @@ -938,7 +937,7 @@ write_port_etc(port_id id, int32 msgCode, const void *msgBuffer, return B_BAD_PORT_ID; } - if (sPorts[slot].closed) { + if (sPorts[slot].capacity == 0) { RELEASE_PORT_LOCK(sPorts[slot]); restore_interrupts(state); TRACE(("write_port_etc: port %ld closed\n", id));