Author: axeld Date: 2009-10-29 09:08:31 +0100 (Thu, 29 Oct 2009) New Revision: 33823 Changeset: http://dev.haiku-os.org/changeset/33823/haiku Modified: haiku/trunk/src/system/kernel/port.cpp Log: * delete_owned_ports() did not maintain the sUsedPorts variable, and thus led to bug #4864. Modified: haiku/trunk/src/system/kernel/port.cpp =================================================================== --- haiku/trunk/src/system/kernel/port.cpp 2009-10-28 21:58:53 UTC (rev 33822) +++ haiku/trunk/src/system/kernel/port.cpp 2009-10-29 08:08:31 UTC (rev 33823) @@ -606,10 +606,25 @@ list_move_to_list(&team->port_list, &queue); } + int32 firstSlot = sMaxPorts; + int32 count = 0; + while (port_entry* port = (port_entry*)list_remove_head_item(&queue)) { + if (firstSlot > port->id % sMaxPorts) + firstSlot = port->id % sMaxPorts; + count++; + MutexLocker locker(port->lock); uninit_port_locked(*port); } + + MutexLocker _(sPortsLock); + + // update the first free slot hint in the array + if (firstSlot < sFirstFreeSlot) + sFirstFreeSlot = firstSlot; + + sUsedPorts -= count; }