summaryrefslogtreecommitdiff
path: root/desktop/unx/source
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com>2012-11-20 11:03:03 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-13 11:16:12 +0100
commit0dce7eae55bf90d2a7171a1fb8663d66ba4ac6d3 (patch)
tree104a391ba1d2d6cdaa2bc121a522c827e45e8577 /desktop/unx/source
parent53fbd30b3cd6465251b1b07f4728813d524fcd82 (diff)
startup: more reliable startup of multiple instances
Until now, when a new soffice instance (S2) started and tried to connect to an existing soffice process (S1), S2 may have failed to boostrap due to race condition in communication over the shared pipe. S1 can be shutdown after S2 connected to it but _before_ S1 handled its arguments (code run after 'accept' method in OfficeIPCThread). This patch introduces a new message, sent by the main soffice after it has called accept if and only if it's not shutting down (see mbDowning member). The other soffice waits for this message before enabling going in PIPE_CONNECTED mode. If soffice fails to receive this message, pipe mode is left unchanged and after a quick pause, it will try again. Change-Id: I2e099a5804e1e8dd535cfd31ef454cffa44efa62 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'desktop/unx/source')
-rw-r--r--desktop/unx/source/start.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 2d12d89e89cc..0e32c590f9de 100644
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -839,10 +839,19 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
{
- rtl_uString *pCwdPath = NULL;
- osl_getProcessWorkingDir( &pCwdPath );
-
- bSentArgs = send_args( fd, pCwdPath );
+ // Wait for answer
+ char resp[ strlen( "InternalIPC::SendArguments" ) + 1];
+ ssize_t n = read( fd, resp, SAL_N_ELEMENTS( resp ) );
+ if (n == (ssize_t) SAL_N_ELEMENTS( resp )
+ && (memcmp(
+ resp, "InternalIPC::SendArguments",
+ SAL_N_ELEMENTS( resp ) - 1) == 0)) {
+ rtl_uString *pCwdPath = NULL;
+ osl_getProcessWorkingDir( &pCwdPath );
+
+ // Then send args
+ bSentArgs = send_args( fd, pCwdPath );
+ }
close( fd );
}