added an new method to be able to port message sto a BSession handler

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6042 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-01-13 00:00:59 +00:00
parent aed7bd673a
commit b0591ec204
+16 -3
View File
@@ -24,9 +24,12 @@
// Description: Class for low-overhead port-based messaging
//
//------------------------------------------------------------------------------
#include <malloc.h>
#include <ServerProtocol.h>
#include "PortLink.h"
#include "PortMessage.h"
#include "Session.h"
PortLink::PortLink(port_id port)
{
@@ -37,7 +40,7 @@ PortLink::PortLink(port_id port)
fReceivePort = create_port(30,"PortLink reply port");
fSendCode = 0;
fSendBuffer=new char[4096];
fSendBuffer = (char*)malloc(4096);//new char[4096];
fSendPosition = 8;
fDataSize = (int32*)(fSendBuffer+sizeof(int32));
*fDataSize = 0;
@@ -51,7 +54,7 @@ PortLink::PortLink( const PortLink &link )
fReceivePort = create_port(30,"PortLink reply port");
fSendCode = 0;
fSendBuffer=new char[4096];
fSendBuffer = (char*)malloc(4096);//new char[4096];
fSendPosition = 8;
fDataSize = (int32*)(fSendBuffer+sizeof(int32));
*fDataSize = 0;
@@ -59,7 +62,7 @@ PortLink::PortLink( const PortLink &link )
PortLink::~PortLink(void)
{
delete [] fSendBuffer;
free(fSendBuffer);//delete [] fSendBuffer;
}
void PortLink::SetOpCode( int32 code )
@@ -120,6 +123,16 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout )
return B_OK;
}
status_t PortLink::FlushToSession(){
BSession ses(0, fSendPort);
// !!!!!!!!!!!!!!!!!!!
// DW, if you modify PortLink, DON'T forget to modify
// BSession::CopyToSendBuffer() as well!!!
// !!!!!!!!!!!!!!!!!!!
ses.CopyToSendBuffer(fSendBuffer, fSendPosition - 8);
ses.Sync();
}
status_t PortLink::Attach(const void *data, size_t size)
{
if (size <= 0)