From f528e1ad7abcdf2b4a4d8c2075a52cc52f658211 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 6 Mar 2009 22:57:36 +0000 Subject: [PATCH] Fix two more problems in the messaging service: 1) When searching the area for a place to allocate the next command, the case of the first command being the same as the last command (as is the case after adding the first message) was not correctly considered. This prevented a given area from ever containing more than one command. 2) The size of a command was incorrectly word-aligned. Rather than aligning to 32-bit boundaries, the size was truncated to between 1-3 bytes, leading to command corruption once multiple messages were in the area, eventually causing registrar to crash while retrieving the messages. Combined these two changes result in us no longer constantly allocating/destroying areas during heavy node monitor activity. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29417 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/messaging/MessagingService.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/messaging/MessagingService.cpp b/src/system/kernel/messaging/MessagingService.cpp index 8f8665641a..de685b41d4 100644 --- a/src/system/kernel/messaging/MessagingService.cpp +++ b/src/system/kernel/messaging/MessagingService.cpp @@ -183,7 +183,7 @@ MessagingArea::AllocateCommand(uint32 commandWhat, int32 dataSize, } // find space for the command - if (firstCommandOffset < lastCommandOffset) { + if (firstCommandOffset <= lastCommandOffset) { // not wrapped // try to allocate after the last command if (size <= fSize - (lastCommandOffset + lastCommandSize)) { @@ -260,7 +260,7 @@ MessagingArea::_CheckCommand(int32 offset, int32 &size) size = command->size; if (size < (int32)sizeof(messaging_command)) return NULL; - size = (size + 3) & 0x3; // align + size = (size + 3) & ~0x3; // align if (offset + size > fSize) return NULL;