summaryrefslogtreecommitdiff
path: root/extensions/source/plugin/unx/mediator.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-03-17 09:15:16 +0000
committerOliver Bolte <obo@openoffice.org>2004-03-17 09:15:16 +0000
commit47ccfcacf6e74790f35e8f5ac13f11bff912bea2 (patch)
tree4f95a3bb479169e2e7ad9eae2b63c147b778fa6b /extensions/source/plugin/unx/mediator.cxx
parent90d70b228c29231ef8d69d52d50f0d2ed13647bc (diff)
INTEGRATION: CWS vcl18 (1.4.138); FILE MERGED
2004/03/16 11:40:08 pl 1.4.138.2: #i12911# try to shutdown pluginapp gracefully in case of certain signals 2004/02/18 18:51:35 pl 1.4.138.1: #110169# finally: flash plugin support
Diffstat (limited to 'extensions/source/plugin/unx/mediator.cxx')
-rw-r--r--extensions/source/plugin/unx/mediator.cxx28
1 files changed, 18 insertions, 10 deletions
diff --git a/extensions/source/plugin/unx/mediator.cxx b/extensions/source/plugin/unx/mediator.cxx
index 994c390f09a6..e2c9d104ffcd 100644
--- a/extensions/source/plugin/unx/mediator.cxx
+++ b/extensions/source/plugin/unx/mediator.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mediator.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: vg $ $Date: 2003-05-28 12:38:21 $
+ * last change: $Author: obo $ $Date: 2004-03-17 10:15:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,8 @@
#include <plugin/unx/mediator.hxx>
#include <vcl/svapp.hxx>
+#define MEDIATOR_MAGIC 0xf7a8d2f4
+
Mediator::Mediator( int nSocket ) :
m_nSocket( nSocket ),
m_pListener( NULL ),
@@ -85,9 +87,10 @@ Mediator::~Mediator()
m_pListener = NULL;
if( m_bValid )
{
- ULONG aHeader[2];
+ ULONG aHeader[3];
aHeader[0] = 0;
aHeader[1] = 0;
+ aHeader[2] = MEDIATOR_MAGIC;
write( m_nSocket, aHeader, sizeof( aHeader ) );
}
// kick the thread out of its run method; it deletes itself
@@ -113,11 +116,12 @@ ULONG Mediator::SendMessage( ULONG nBytes, const char* pBytes, ULONG nMessageID
if( ! m_bValid )
return nMessageID;
- ULONG* pBuffer = new ULONG[ (nBytes/sizeof(ULONG)) + 3 ];
+ ULONG* pBuffer = new ULONG[ (nBytes/sizeof(ULONG)) + 4 ];
pBuffer[ 0 ] = nMessageID;
pBuffer[ 1 ] = nBytes;
- memcpy( &pBuffer[2], pBytes, (size_t)nBytes );
- write( m_nSocket, pBuffer, nBytes + 2*sizeof( ULONG ) );
+ pBuffer[ 2 ] = MEDIATOR_MAGIC;
+ memcpy( &pBuffer[3], pBytes, (size_t)nBytes );
+ write( m_nSocket, pBuffer, nBytes + 3*sizeof( ULONG ) );
delete [] pBuffer;
return nMessageID;
@@ -199,12 +203,13 @@ MediatorListener::~MediatorListener()
void MediatorListener::run()
{
- while( schedule() && m_pMediator )
+ bool bRun = true;
+ while( schedule() && m_pMediator && bRun )
{
- ULONG nHeader[ 2 ];
+ ULONG nHeader[ 3 ];
int nBytes;
- if( m_pMediator && ( nBytes = read( m_pMediator->m_nSocket, nHeader, sizeof( nHeader ) ) ) == sizeof( nHeader ) )
+ if( m_pMediator && ( nBytes = read( m_pMediator->m_nSocket, nHeader, sizeof( nHeader ) ) ) == sizeof( nHeader ) && nHeader[2] == MEDIATOR_MAGIC)
{
if( nHeader[ 0 ] == 0 && nHeader[ 1 ] == 0 )
return;
@@ -223,15 +228,18 @@ void MediatorListener::run()
m_pMediator->m_aNewMessageHdl.Call( m_pMediator );
}
else
+ {
medDebug( 1, "got incomplete MediatorMessage: { %d, %d, %*s }\n",
nHeader[0], nHeader[1], nHeader[1], pBuffer );
+ bRun = false;
+ }
delete [] pBuffer;
}
else
{
medDebug( 1, "got incomplete message header of %d bytes ( nHeader = [ %u, %u ] ), errno is %d\n",
nBytes, nHeader[ 0 ], nHeader[ 1 ], (int)errno );
- break;
+ bRun = false;
}
}
}