no-copy socket read

This commit is contained in:
Matej Sekoranja
2011-08-28 10:10:56 +02:00
parent 872135a4b1
commit 44d092ffa7
2 changed files with 7 additions and 13 deletions

View File

@@ -160,7 +160,6 @@ namespace epics {
// This function is always called from only one thread - this
// object's own thread.
char _readBuffer[MAX_UDP_RECV];
osiSockAddr fromAddress;
Transport::shared_pointer thisTransport = shared_from_this();
@@ -183,8 +182,8 @@ namespace epics {
socklen_t addrStructSize = sizeof(sockaddr);
int bytesRead = recvfrom(_channel, _readBuffer,
MAX_UDP_RECV, 0, (sockaddr*)&fromAddress,
int bytesRead = recvfrom(_channel, (void*)_receiveBuffer->getArray(),
_receiveBuffer->getRemaining(), 0, (sockaddr*)&fromAddress,
&addrStructSize);
if(bytesRead>0) {
@@ -203,11 +202,7 @@ namespace epics {
}
if(!ignore) {
// TODO do not copy.... wrap the buffer!!!
_receiveBuffer->put(_readBuffer, 0,
bytesRead <_receiveBuffer->getRemaining() ?
bytesRead : _receiveBuffer->getRemaining()
);
_receiveBuffer->setPosition(bytesRead);
_receiveBuffer->flip();