From 75d1cb286f381c2255293cc0fb78d50454887e19 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 6 Mar 2009 05:45:32 +0000 Subject: [PATCH] The loop that looks for the next area to add a message to has a somewhat fatal flaw: it checks for a non-zero area size (which is always set to the physical size of the area rather than the number of message commands stored within it). As a consequence, areas would never get cleaned up once allocated, which lead the kernel to steadily bleed memory if any reasonable level of node monitoring activity was going on. We now check whether or not the area's command count is non-zero instead, and use that as the criteria for selection. Fixes ticket #3518. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29411 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/messaging/MessagingService.cpp | 10 +++++++++- src/system/kernel/messaging/MessagingService.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/messaging/MessagingService.cpp b/src/system/kernel/messaging/MessagingService.cpp index f2f2f923c0..c0dc43ac21 100644 --- a/src/system/kernel/messaging/MessagingService.cpp +++ b/src/system/kernel/messaging/MessagingService.cpp @@ -138,6 +138,14 @@ MessagingArea::Size() const } +// Empty +bool +MessagingArea::IsEmpty() const +{ + return fHeader->command_count == 0; +} + + // AllocateCommand void * MessagingArea::AllocateCommand(uint32 commandWhat, int32 dataSize, @@ -445,7 +453,7 @@ MessagingService::_AllocateCommand(int32 commandWhat, int32 size, while (fFirstArea != fLastArea) { area = fFirstArea; area->Lock(); - if (area->Size() != 0) { + if (!area->IsEmpty()) { area->Unlock(); break; } diff --git a/src/system/kernel/messaging/MessagingService.h b/src/system/kernel/messaging/MessagingService.h index 97705d8a18..0e913bc764 100644 --- a/src/system/kernel/messaging/MessagingService.h +++ b/src/system/kernel/messaging/MessagingService.h @@ -30,6 +30,7 @@ public: area_id ID() const; int32 Size() const; + bool IsEmpty() const; void *AllocateCommand(uint32 commandWhat, int32 dataSize, bool &wasEmpty); void CommitCommand();