diff options
author | Andrzej J. R. Hunt <andrzej@ahunt.org> | 2012-07-18 16:14:52 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-08-06 10:22:58 +0100 |
commit | 6d6b6ee2750aa181c37464d9253b01509036b2ba (patch) | |
tree | edb66c4ed4e10e9ca5021f6daa557e6c0e2b2eac /sd/source/ui/remotecontrol/Transmitter.cxx | |
parent | 38b4c55546dc91e6f90f24b6e8b30530a3093fcf (diff) |
Fixed segfault on use of transmitter, and transmitter lifecycle.
Change-Id: I3983b28443584f33a879ba9fab52f11a0ab7fad5
Diffstat (limited to 'sd/source/ui/remotecontrol/Transmitter.cxx')
-rw-r--r-- | sd/source/ui/remotecontrol/Transmitter.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sd/source/ui/remotecontrol/Transmitter.cxx b/sd/source/ui/remotecontrol/Transmitter.cxx index dbe902b8bd98..341438b5dcfd 100644 --- a/sd/source/ui/remotecontrol/Transmitter.cxx +++ b/sd/source/ui/remotecontrol/Transmitter.cxx @@ -15,9 +15,12 @@ using namespace sd; Transmitter::Transmitter( StreamSocket &aSocket ) : Thread( "TransmitterThread" ), - mStreamSocket( aSocket ) + mStreamSocket( aSocket ), + mQueuesNotEmpty(), + mQueueMutex(), + mLowPriority(), + mHighPriority() { - launch(); } void @@ -29,7 +32,7 @@ Transmitter::execute() fprintf( stderr, "Continuing after condition\n" ); while ( true ) { - osl::MutexGuard aQueueGuard( mQueueMutex ); + ::osl::MutexGuard aQueueGuard( mQueueMutex ); while ( mHighPriority.size() ) { OString aMessage( mHighPriority.front() ); @@ -46,7 +49,7 @@ Transmitter::execute() mStreamSocket.write( aMessage.getStr(), aMessage.getLength() ); } - if ( (mLowPriority.size() == 0) && (mHighPriority.size() == 0) ) + if ( mLowPriority.empty() && mHighPriority.empty() ) { mQueuesNotEmpty.reset(); break; @@ -62,19 +65,25 @@ Transmitter::~Transmitter() } -void Transmitter::addMessage( const OString aMessage, const Priority aPriority ) +void Transmitter::addMessage( const OString& aMessage, const Priority aPriority ) { - osl::MutexGuard aQueueGuard( mQueueMutex ); + fprintf(stderr, "Acquiring\n"); + ::osl::MutexGuard aQueueGuard( mQueueMutex ); + fprintf(stderr, "Acquired\n" ); switch ( aPriority ) { case Priority::LOW: + fprintf(stderr, "PushingLow\n"); mLowPriority.push( aMessage ); break; case Priority::HIGH: + fprintf(stderr, "PushingHigh\n%s\n", aMessage.getStr() ); mHighPriority.push( aMessage ); break; } - mQueuesNotEmpty.set(); + fprintf( stderr, "Setting\n" ); + if ( !mQueuesNotEmpty.check() ) + mQueuesNotEmpty.set(); fprintf( stderr, "Added\n" ); } |