Accidently broke BMessage::_SendFlattenedMessage() with the last commit;

the magic is not part of the header anymore when read from a stream (because
BDataIO does not support seeking, and we need to know the magic before actually
reading the header).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13429 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-07-05 00:03:18 +00:00
parent dc9e836b35
commit 749a772b97

View File

@ -2030,17 +2030,23 @@ BMessage::_SendFlattenedMessage(void *data, int32 size, port_id port,
if (!data)
return B_BAD_VALUE;
uint32 magic = *(uint32*)data;
// prepare flattened fields
if (((KMessage::Header*)data)->magic == KMessage::kMessageHeaderMagic) {
// a KMessage
KMessage::Header *header = (KMessage::Header*)data;
header->targetToken = (preferred ? B_PREFERRED_TOKEN : token);
} else if (*(uint32*)data == kMessageMagic
|| *(uint32*)data == kMessageMagicSwapped) {
// get the header
BMemoryIO stream(data, size);
} else if (magic == kMessageMagic || magic == kMessageMagicSwapped) {
// get the header (but not the magic again)
BMemoryIO stream((uint32 *)data + 1, size - sizeof(uint32));
Header header;
status_t error = header.ReadFrom(stream);
status_t error = header.SetMagic(magic);
if (error != B_OK)
return error;
error = header.ReadFrom(stream);
if (error != B_OK)
return error;