summaryrefslogtreecommitdiff
path: root/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/remotecontrol/BufferedStreamSocket.cxx')
-rw-r--r--sd/source/ui/remotecontrol/BufferedStreamSocket.cxx30
1 files changed, 17 insertions, 13 deletions
diff --git a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
index 8232bd085a06..0e274c30295a 100644
--- a/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
+++ b/sd/source/ui/remotecontrol/BufferedStreamSocket.cxx
@@ -27,8 +27,25 @@ sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
{
while ( true )
{
+ // Process buffer first incase data already present.
+ vector<char>::iterator aIt;
+ if ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
+ != aBuffer.end() )
+ {
+ sal_uInt64 aLocation = aIt - aBuffer.begin();
+
+ aLine = OString( &(*aBuffer.begin()), aLocation );
+
+ aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
+ aRead -= (aLocation + 1);
+
+ return aLine.getLength();
+ }
+
+ // Then try and receive if nothing present
aBuffer.resize( aRead + 100 );
aRet = recv( &aBuffer[aRead], 100 );
+
if ( aRet == 0 )
{
return aRet;
@@ -40,19 +57,6 @@ sal_Int32 BufferedStreamSocket::readLine( OString& aLine )
return 0;
}
aRead += aRet;
- vector<char>::iterator aIt;
- while ( (aIt = find( aBuffer.begin(), aBuffer.end(), '\n' ))
- != aBuffer.end() )
- {
- sal_uInt64 aLocation = aIt - aBuffer.begin();
-
- aLine = OString( &(*aBuffer.begin()), aLocation );
-
- aBuffer.erase( aBuffer.begin(), aIt + 1 ); // Also delete the empty line
- aRead -= (aLocation + 1);
-
- return aLine.getLength();
- }
}