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
This commit is contained in:
Rene Gollent 2009-03-06 22:57:36 +00:00
parent 70e72d56e7
commit f528e1ad7a

View File

@ -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;