Updates to sync with (hopefully) final tweaks to messaging protocols
Implemented BSession::DropInputBuffer with code from Adi git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fb7da50d34
commit
83f9647173
@ -60,7 +60,7 @@
|
|||||||
// Local Defines ---------------------------------------------------------------
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
// Uncomment this to run without the registrar - used only for app_server development!
|
// Uncomment this to run without the registrar - used only for app_server development!
|
||||||
//#define RUN_WITHOUT_REGISTRAR
|
#define RUN_WITHOUT_REGISTRAR
|
||||||
|
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
// Globals ---------------------------------------------------------------------
|
||||||
|
@ -38,7 +38,9 @@ PortLink::PortLink(port_id port)
|
|||||||
|
|
||||||
fSendCode=0;
|
fSendCode=0;
|
||||||
fSendBuffer=new char[4096];
|
fSendBuffer=new char[4096];
|
||||||
fSendPosition=4;
|
fSendPosition=8;
|
||||||
|
fDataSize=(int32*)fSendBuffer+sizeof(int32);
|
||||||
|
*fDataSize=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortLink::PortLink( const PortLink &link )
|
PortLink::PortLink( const PortLink &link )
|
||||||
@ -50,7 +52,9 @@ PortLink::PortLink( const PortLink &link )
|
|||||||
|
|
||||||
fSendCode = 0;
|
fSendCode = 0;
|
||||||
fSendBuffer=new char[4096];
|
fSendBuffer=new char[4096];
|
||||||
fSendPosition = 4;
|
fSendPosition = 8;
|
||||||
|
fDataSize=(int32*)fSendBuffer+sizeof(int32);
|
||||||
|
*fDataSize=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortLink::~PortLink(void)
|
PortLink::~PortLink(void)
|
||||||
@ -86,12 +90,13 @@ status_t PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if(timeout!=B_INFINITE_TIMEOUT)
|
if(timeout!=B_INFINITE_TIMEOUT)
|
||||||
write_stat=write_port_etc(fSendPort, fSendCode, fSendBuffer,
|
write_stat=write_port_etc(fSendPort, AS_SERVER_PORTLINK, fSendBuffer,
|
||||||
fSendPosition, B_TIMEOUT, timeout);
|
fSendPosition, B_TIMEOUT, timeout);
|
||||||
else
|
else
|
||||||
write_stat=write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition);
|
write_stat=write_port(fSendPort, AS_SERVER_PORTLINK, fSendBuffer, fSendPosition);
|
||||||
|
|
||||||
fSendPosition=4;
|
fSendPosition=8;
|
||||||
|
*fDataSize=0;
|
||||||
|
|
||||||
return write_stat;
|
return write_stat;
|
||||||
}
|
}
|
||||||
@ -105,30 +110,12 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE
|
|||||||
Attach<int32>(fReceivePort);
|
Attach<int32>(fReceivePort);
|
||||||
|
|
||||||
// Flush the thing....FOOSH! :P
|
// Flush the thing....FOOSH! :P
|
||||||
write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition);
|
write_port(fSendPort, AS_SERVER_PORTLINK, fSendBuffer, fSendPosition);
|
||||||
fSendPosition = 4;
|
fSendPosition = 8;
|
||||||
|
*fDataSize=0;
|
||||||
|
|
||||||
// Now we wait for the reply
|
// Now we wait for the reply
|
||||||
ssize_t rbuffersize;
|
msg->ReadFromPort(fReceivePort,timeout);
|
||||||
int8 *rbuffer = NULL;
|
|
||||||
int32 rcode;
|
|
||||||
|
|
||||||
if( timeout == B_INFINITE_TIMEOUT )
|
|
||||||
rbuffersize = port_buffer_size(fReceivePort);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rbuffersize = port_buffer_size_etc( fReceivePort, 0, timeout);
|
|
||||||
if( rbuffersize == B_TIMED_OUT )
|
|
||||||
return B_TIMED_OUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( rbuffersize > 0 )
|
|
||||||
rbuffer = new int8[rbuffersize];
|
|
||||||
read_port( fReceivePort, &rcode, rbuffer, rbuffersize);
|
|
||||||
|
|
||||||
// We got this far, so we apparently have some data
|
|
||||||
msg->SetCode(rcode);
|
|
||||||
msg->SetBuffer(rbuffer,rbuffersize,false);
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -138,9 +125,11 @@ status_t PortLink::Attach(const void *data, size_t size)
|
|||||||
if (size <= 0)
|
if (size <= 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
if (4096 - fSendPosition > (int32)size){
|
if (4096 - fSendPosition > (int32)size)
|
||||||
|
{
|
||||||
memcpy(fSendBuffer + fSendPosition, data, size);
|
memcpy(fSendBuffer + fSendPosition, data, size);
|
||||||
fSendPosition += size;
|
fSendPosition += size;
|
||||||
|
*fDataSize+=size;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@ -156,6 +145,7 @@ status_t PortLink::AttachString(const char *string)
|
|||||||
|
|
||||||
void PortLink::MakeEmpty()
|
void PortLink::MakeEmpty()
|
||||||
{
|
{
|
||||||
fSendPosition=4;
|
fSendPosition=8;
|
||||||
|
*fDataSize=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,14 @@ PortMessage::PortMessage(const int32 &code, const void *buffer, const ssize_t &b
|
|||||||
const bool ©)
|
const bool ©)
|
||||||
{
|
{
|
||||||
_code=code;
|
_code=code;
|
||||||
|
_protocol=AS_SERVER_PORTLINK;
|
||||||
SetBuffer(buffer,buffersize,copy);
|
SetBuffer(buffer,buffersize,copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
PortMessage::PortMessage(void)
|
PortMessage::PortMessage(void)
|
||||||
{
|
{
|
||||||
_code=0;
|
_code=0;
|
||||||
|
_protocol=AS_SERVER_PORTLINK;
|
||||||
_buffer=NULL;
|
_buffer=NULL;
|
||||||
_buffersize=0;
|
_buffersize=0;
|
||||||
_index=NULL;
|
_index=NULL;
|
||||||
@ -77,9 +79,11 @@ status_t PortMessage::ReadFromPort(const port_id &port, const bigtime_t &timeout
|
|||||||
|
|
||||||
if(_buffersize>0)
|
if(_buffersize>0)
|
||||||
_buffer=new uint8[_buffersize];
|
_buffer=new uint8[_buffersize];
|
||||||
read_port(port, &_code, _buffer, _buffersize);
|
read_port(port, &_protocol, _buffer, _buffersize);
|
||||||
|
if(_buffer)
|
||||||
|
_code=*((int32*)_buffer);
|
||||||
|
|
||||||
_index=_buffer+4;
|
_index=_buffer+8;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -94,7 +98,7 @@ status_t PortMessage::WriteToPort(const port_id &port)
|
|||||||
int32 *cast=(int32*)_buffer;
|
int32 *cast=(int32*)_buffer;
|
||||||
*cast=_code;
|
*cast=_code;
|
||||||
|
|
||||||
write_port(port,_code, _buffer, _buffersize);
|
write_port(port, AS_SERVER_PORTLINK, _buffer, _buffersize);
|
||||||
|
|
||||||
if(_buffer && _buffersize>0)
|
if(_buffer && _buffersize>0)
|
||||||
{
|
{
|
||||||
@ -132,7 +136,7 @@ void PortMessage::SetBuffer(const void *buffer, const ssize_t &size, const bool
|
|||||||
_buffersize=size;
|
_buffersize=size;
|
||||||
_buffer=(uint8 *)buffer;
|
_buffer=(uint8 *)buffer;
|
||||||
}
|
}
|
||||||
_index=_buffer+4;
|
_index=_buffer+8;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t PortMessage::Read(void *data, ssize_t size)
|
status_t PortMessage::Read(void *data, ssize_t size)
|
||||||
@ -152,7 +156,7 @@ status_t PortMessage::Read(void *data, ssize_t size)
|
|||||||
|
|
||||||
void PortMessage::Rewind(void)
|
void PortMessage::Rewind(void)
|
||||||
{
|
{
|
||||||
_index=_buffer+4;
|
_index=_buffer+8;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t PortMessage::ReadString(char **string)
|
status_t PortMessage::ReadString(char **string)
|
||||||
|
@ -54,7 +54,10 @@ void BSession::SetRecvPort( port_id port ){
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool BSession::DropInputBuffer(void){
|
bool BSession::DropInputBuffer(void){
|
||||||
// TODO: Implement
|
// doesn't matter their value, they just need to be equal.
|
||||||
|
fReceiveSize = 1024;
|
||||||
|
fReceivePosition = 1024;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BSession::SetMsgCode(int32 code){
|
void BSession::SetMsgCode(int32 code){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user