From d98326b49f97c554f8a3b22a116ff76b893d4a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 28 Jun 2003 16:53:36 +0000 Subject: [PATCH] Removed some useless calls to get_sem_count(). Moved set_port_owner() around. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3717 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/port.c | 76 ++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/src/kernel/core/port.c b/src/kernel/core/port.c index d81b85b69b..2dac4b6080 100644 --- a/src/kernel/core/port.c +++ b/src/kernel/core/port.c @@ -736,39 +736,6 @@ read_port_etc(port_id id, int32 *msgCode, void *msgBuffer, size_t bufferSize, } -status_t -set_port_owner(port_id id, team_id team) -{ - int slot; - int state; - - if (ports_active == false - || id < 0) - return B_BAD_PORT_ID; - - slot = id % MAX_PORTS; - - state = disable_interrupts(); - GRAB_PORT_LOCK(ports[slot]); - - if (ports[slot].id != id) { - RELEASE_PORT_LOCK(ports[slot]); - restore_interrupts(state); - dprintf("set_port_owner: invalid port_id %ld\n", id); - return B_BAD_PORT_ID; - } - - // transfer ownership to other team - ports[slot].owner = team; - - // unlock port - RELEASE_PORT_LOCK(ports[slot]); - restore_interrupts(state); - - return B_NO_ERROR; -} - - status_t write_port(port_id id, int32 msgCode, const void *msgBuffer, size_t bufferSize) { @@ -786,7 +753,6 @@ write_port_etc(port_id id, int32 msgCode, const void *msgBuffer, sem_id cached_semid; int h; cbuf *msgStore; - int32 c1, c2; bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) > 0; if (ports_active == false @@ -887,10 +853,6 @@ write_port_etc(port_id id, int32 msgCode, const void *msgBuffer, RELEASE_PORT_LOCK(ports[slot]); restore_interrupts(state); - // ToDo: what is this needed for? - get_sem_count(ports[slot].read_sem, &c1); - get_sem_count(ports[slot].write_sem, &c2); - // release sem, allowing read (might reschedule) release_sem(cached_semid); @@ -898,8 +860,42 @@ write_port_etc(port_id id, int32 msgCode, const void *msgBuffer, } -/* this function cycles through the ports table, deleting all the ports that are owned by - the passed team_id */ +status_t +set_port_owner(port_id id, team_id team) +{ + int slot; + int state; + + if (ports_active == false + || id < 0) + return B_BAD_PORT_ID; + + slot = id % MAX_PORTS; + + state = disable_interrupts(); + GRAB_PORT_LOCK(ports[slot]); + + if (ports[slot].id != id) { + RELEASE_PORT_LOCK(ports[slot]); + restore_interrupts(state); + dprintf("set_port_owner: invalid port_id %ld\n", id); + return B_BAD_PORT_ID; + } + + // transfer ownership to other team + ports[slot].owner = team; + + // unlock port + RELEASE_PORT_LOCK(ports[slot]); + restore_interrupts(state); + + return B_NO_ERROR; +} + + +/** this function cycles through the ports table, deleting all + * the ports that are owned by the passed team_id + */ int delete_owned_ports(team_id owner)