Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
40d21ab3
Kaydet (Commit)
40d21ab3
authored
Şub 23, 2012
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Adapted OfficeIPCThread to safer-to-use salhelper::Thread
üst
e4c7862b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
34 deletions
+36
-34
Library_sofficeapp.mk
desktop/Library_sofficeapp.mk
+1
-0
build.lst
desktop/prj/build.lst
+1
-1
officeipcthread.cxx
desktop/source/app/officeipcthread.cxx
+24
-25
officeipcthread.hxx
desktop/source/app/officeipcthread.hxx
+10
-8
No files found.
desktop/Library_sofficeapp.mk
Dosyayı görüntüle @
40d21ab3
...
@@ -53,6 +53,7 @@ $(eval $(call gb_Library_add_linked_libs,sofficeapp,\
...
@@ -53,6 +53,7 @@ $(eval $(call gb_Library_add_linked_libs,sofficeapp,\
deploymentmisc \
deploymentmisc \
i18nisolang1 \
i18nisolang1 \
sal \
sal \
salhelper \
sfx \
sfx \
svl \
svl \
svt \
svt \
...
...
desktop/prj/build.lst
Dosyayı görüntüle @
40d21ab3
dt desktop : TRANSLATIONS:translations sfx2 stoc BERKELEYDB:berkeleydb sysui BOOST:boost svx DESKTOP:xmlhelp sal unoil officecfg offapi filter LIBXSLT:libxslt NULL
dt desktop : TRANSLATIONS:translations sfx2 stoc BERKELEYDB:berkeleydb sysui BOOST:boost svx DESKTOP:xmlhelp sal
salhelper
unoil officecfg offapi filter LIBXSLT:libxslt NULL
dt desktop usr1 - all dt_mkout NULL
dt desktop usr1 - all dt_mkout NULL
dt desktop\prj nmake - all dt_prj NULL
dt desktop\prj nmake - all dt_prj NULL
desktop/source/app/officeipcthread.cxx
Dosyayı görüntüle @
40d21ab3
...
@@ -220,7 +220,7 @@ bool addArgument(rtl::OStringBuffer &rArguments, char prefix,
...
@@ -220,7 +220,7 @@ bool addArgument(rtl::OStringBuffer &rArguments, char prefix,
}
}
OfficeIPCThread
*
OfficeIPCThread
::
pGlobalOfficeIPCThread
=
0
;
rtl
::
Reference
<
OfficeIPCThread
>
OfficeIPCThread
::
pGlobalOfficeIPCThread
;
namespace
{
struct
Security
:
public
rtl
::
Static
<
osl
::
Security
,
Security
>
{};
}
namespace
{
struct
Security
:
public
rtl
::
Static
<
osl
::
Security
,
Security
>
{};
}
// Turns a string in aMsg such as file:///home/foo/.libreoffice/3
// Turns a string in aMsg such as file:///home/foo/.libreoffice/3
...
@@ -376,7 +376,7 @@ void OfficeIPCThread::SetDowning()
...
@@ -376,7 +376,7 @@ void OfficeIPCThread::SetDowning()
// requests are executed anymore.
// requests are executed anymore.
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
pGlobalOfficeIPCThread
->
mbDowning
=
true
;
pGlobalOfficeIPCThread
->
mbDowning
=
true
;
}
}
...
@@ -387,7 +387,7 @@ void OfficeIPCThread::EnableRequests( bool i_bEnable )
...
@@ -387,7 +387,7 @@ void OfficeIPCThread::EnableRequests( bool i_bEnable )
// switch between just queueing the requests and executing them
// switch between just queueing the requests and executing them
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
{
{
s_bInEnableRequests
=
true
;
s_bInEnableRequests
=
true
;
pGlobalOfficeIPCThread
->
mbRequestsEnabled
=
i_bEnable
;
pGlobalOfficeIPCThread
->
mbRequestsEnabled
=
i_bEnable
;
...
@@ -406,7 +406,7 @@ sal_Bool OfficeIPCThread::AreRequestsPending()
...
@@ -406,7 +406,7 @@ sal_Bool OfficeIPCThread::AreRequestsPending()
{
{
// Give info about pending requests
// Give info about pending requests
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
return
(
pGlobalOfficeIPCThread
->
mnPendingRequests
>
0
);
return
(
pGlobalOfficeIPCThread
->
mnPendingRequests
>
0
);
else
else
return
sal_False
;
return
sal_False
;
...
@@ -416,7 +416,7 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
...
@@ -416,7 +416,7 @@ void OfficeIPCThread::RequestsCompleted( int nCount )
{
{
// Remove nCount pending requests from our internal counter
// Remove nCount pending requests from our internal counter
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
{
{
if
(
pGlobalOfficeIPCThread
->
mnPendingRequests
>
0
)
if
(
pGlobalOfficeIPCThread
->
mnPendingRequests
>
0
)
pGlobalOfficeIPCThread
->
mnPendingRequests
-=
nCount
;
pGlobalOfficeIPCThread
->
mnPendingRequests
-=
nCount
;
...
@@ -427,13 +427,13 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
...
@@ -427,13 +427,13 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
{
{
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
::
osl
::
MutexGuard
aGuard
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
return
IPC_STATUS_OK
;
return
IPC_STATUS_OK
;
::
rtl
::
OUString
aUserInstallPath
;
::
rtl
::
OUString
aUserInstallPath
;
::
rtl
::
OUString
aDummy
;
::
rtl
::
OUString
aDummy
;
OfficeIPCThread
*
pThread
=
new
OfficeIPCThread
;
rtl
::
Reference
<
OfficeIPCThread
>
pThread
(
new
OfficeIPCThread
)
;
pThread
->
maPipeIdent
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"SingleOfficeIPC_"
)
);
pThread
->
maPipeIdent
=
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"SingleOfficeIPC_"
)
);
...
@@ -444,7 +444,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
...
@@ -444,7 +444,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
aDummy
=
aUserInstallPath
;
aDummy
=
aUserInstallPath
;
else
else
{
{
delete
pThread
;
return
IPC_STATUS_BOOTSTRAP_ERROR
;
return
IPC_STATUS_BOOTSTRAP_ERROR
;
}
}
...
@@ -530,7 +529,7 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
...
@@ -530,7 +529,7 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
{
{
// Seems we are the one and only, so start listening thread
// Seems we are the one and only, so start listening thread
pGlobalOfficeIPCThread
=
pThread
;
pGlobalOfficeIPCThread
=
pThread
;
pThread
->
create
();
// starts thread
pThread
->
launch
();
}
}
else
else
{
{
...
@@ -562,7 +561,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
...
@@ -562,7 +561,6 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
int
n
=
aStreamPipe
.
read
(
aReceiveBuffer
,
aToken
.
Len
()
);
int
n
=
aStreamPipe
.
read
(
aReceiveBuffer
,
aToken
.
Len
()
);
aReceiveBuffer
[
n
]
=
'\0'
;
aReceiveBuffer
[
n
]
=
'\0'
;
delete
pThread
;
if
(
aToken
.
CompareTo
(
aReceiveBuffer
)
!=
COMPARE_EQUAL
)
{
if
(
aToken
.
CompareTo
(
aReceiveBuffer
)
!=
COMPARE_EQUAL
)
{
// something went wrong
// something went wrong
delete
[]
aReceiveBuffer
;
delete
[]
aReceiveBuffer
;
...
@@ -580,10 +578,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
...
@@ -580,10 +578,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
{
{
osl
::
ClearableMutexGuard
aMutex
(
GetMutex
()
);
osl
::
ClearableMutexGuard
aMutex
(
GetMutex
()
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
{
{
OfficeIPCThread
*
pOfficeIPCThread
=
pGlobalOfficeIPCThread
;
rtl
::
Reference
<
OfficeIPCThread
>
pOfficeIPCThread
(
pGlobalOfficeIPCThread
=
0
;
pGlobalOfficeIPCThread
);
pGlobalOfficeIPCThread
.
clear
();
// send thread a termination message
// send thread a termination message
// this is done so the subsequent join will not hang
// this is done so the subsequent join will not hang
...
@@ -605,13 +604,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
...
@@ -605,13 +604,11 @@ void OfficeIPCThread::DisableOfficeIPCThread()
// exit gracefully and join
// exit gracefully and join
pOfficeIPCThread
->
join
();
pOfficeIPCThread
->
join
();
delete
pOfficeIPCThread
;
}
}
}
}
OfficeIPCThread
::
OfficeIPCThread
()
:
OfficeIPCThread
::
OfficeIPCThread
()
:
Thread
(
"OfficeIPCThread"
),
mbDowning
(
false
),
mbDowning
(
false
),
mbRequestsEnabled
(
false
),
mbRequestsEnabled
(
false
),
mnPendingRequests
(
0
),
mnPendingRequests
(
0
),
...
@@ -627,7 +624,7 @@ OfficeIPCThread::~OfficeIPCThread()
...
@@ -627,7 +624,7 @@ OfficeIPCThread::~OfficeIPCThread()
mpDispatchWatcher
->
release
();
mpDispatchWatcher
->
release
();
maPipe
.
close
();
maPipe
.
close
();
maStreamPipe
.
close
();
maStreamPipe
.
close
();
pGlobalOfficeIPCThread
=
0
;
pGlobalOfficeIPCThread
.
clear
()
;
}
}
static
void
AddURLToStringList
(
const
rtl
::
OUString
&
aURL
,
rtl
::
OUString
&
aStringList
)
static
void
AddURLToStringList
(
const
rtl
::
OUString
&
aURL
,
rtl
::
OUString
&
aStringList
)
...
@@ -639,16 +636,18 @@ static void AddURLToStringList( const rtl::OUString& aURL, rtl::OUString& aStrin
...
@@ -639,16 +636,18 @@ static void AddURLToStringList( const rtl::OUString& aURL, rtl::OUString& aStrin
aStringList
=
aStringListBuf
.
makeStringAndClear
();
aStringList
=
aStringListBuf
.
makeStringAndClear
();
}
}
void
OfficeIPCThread
::
SetReady
(
OfficeIPCThread
*
pThread
)
void
OfficeIPCThread
::
SetReady
(
rtl
::
Reference
<
OfficeIPCThread
>
const
&
pThread
)
{
{
if
(
pThread
==
NULL
)
pThread
=
pGlobalOfficeIPCThread
;
rtl
::
Reference
<
OfficeIPCThread
>
const
&
t
(
if
(
pThread
!=
NULL
)
pThread
.
is
()
?
pThread
:
pGlobalOfficeIPCThread
);
if
(
t
.
is
())
{
{
pThread
->
cReady
.
set
();
t
->
cReady
.
set
();
}
}
}
}
void
SAL_CALL
OfficeIPCThread
::
run
()
void
OfficeIPCThread
::
execute
()
{
{
do
do
{
{
...
@@ -664,7 +663,7 @@ void SAL_CALL OfficeIPCThread::run()
...
@@ -664,7 +663,7 @@ void SAL_CALL OfficeIPCThread::run()
cReady
.
wait
();
cReady
.
wait
();
// we might have decided to shutdown while we were sleeping
// we might have decided to shutdown while we were sleeping
if
(
!
pGlobalOfficeIPCThread
)
return
;
if
(
!
pGlobalOfficeIPCThread
.
is
()
)
return
;
// only lock the mutex when processing starts, othewise we deadlock when the office goes
// only lock the mutex when processing starts, othewise we deadlock when the office goes
// down during wait
// down during wait
...
@@ -894,7 +893,7 @@ void SAL_CALL OfficeIPCThread::run()
...
@@ -894,7 +893,7 @@ void SAL_CALL OfficeIPCThread::run()
TimeValue
tval
;
TimeValue
tval
;
tval
.
Seconds
=
1
;
tval
.
Seconds
=
1
;
tval
.
Nanosec
=
0
;
tval
.
Nanosec
=
0
;
wait
(
tval
);
osl
::
Thread
::
wait
(
tval
);
}
}
}
while
(
schedule
()
);
}
while
(
schedule
()
);
}
}
...
@@ -997,7 +996,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequ
...
@@ -997,7 +996,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequ
AddConversionsToDispatchList
(
aDispatchList
,
aRequest
.
aCwdUrl
,
aRequest
.
aConversionList
,
aRequest
.
aConversionParams
,
aRequest
.
aPrinterName
,
aRequest
.
aModule
,
aRequest
.
aConversionOut
);
AddConversionsToDispatchList
(
aDispatchList
,
aRequest
.
aCwdUrl
,
aRequest
.
aConversionList
,
aRequest
.
aConversionParams
,
aRequest
.
aPrinterName
,
aRequest
.
aModule
,
aRequest
.
aConversionOut
);
sal_Bool
bShutdown
(
sal_False
);
sal_Bool
bShutdown
(
sal_False
);
if
(
pGlobalOfficeIPCThread
)
if
(
pGlobalOfficeIPCThread
.
is
()
)
{
{
if
(
!
pGlobalOfficeIPCThread
->
AreRequestsEnabled
()
)
if
(
!
pGlobalOfficeIPCThread
->
AreRequestsEnabled
()
)
return
bShutdown
;
return
bShutdown
;
...
...
desktop/source/app/officeipcthread.hxx
Dosyayı görüntüle @
40d21ab3
...
@@ -34,10 +34,11 @@
...
@@ -34,10 +34,11 @@
#include <osl/pipe.hxx>
#include <osl/pipe.hxx>
#include <osl/security.hxx>
#include <osl/security.hxx>
#include <osl/signal.h>
#include <osl/signal.h>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustring.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase2.hxx>
#include <osl/conditn.hxx>
#include <osl/conditn.hxx>
#include <
osl
/thread.hxx>
#include <
salhelper
/thread.hxx>
#include "boost/optional.hpp"
#include "boost/optional.hpp"
namespace
desktop
namespace
desktop
...
@@ -70,10 +71,10 @@ struct ProcessDocumentsRequest
...
@@ -70,10 +71,10 @@ struct ProcessDocumentsRequest
};
};
class
DispatchWatcher
;
class
DispatchWatcher
;
class
OfficeIPCThread
:
public
osl
::
Thread
class
OfficeIPCThread
:
public
salhelper
::
Thread
{
{
private
:
private
:
static
OfficeIPCThread
*
pGlobalOfficeIPCThread
;
static
rtl
::
Reference
<
OfficeIPCThread
>
pGlobalOfficeIPCThread
;
osl
::
Pipe
maPipe
;
osl
::
Pipe
maPipe
;
osl
::
StreamPipe
maStreamPipe
;
osl
::
StreamPipe
maStreamPipe
;
...
@@ -101,9 +102,10 @@ class OfficeIPCThread : public osl::Thread
...
@@ -101,9 +102,10 @@ class OfficeIPCThread : public osl::Thread
OfficeIPCThread
();
OfficeIPCThread
();
protected
:
virtual
~
OfficeIPCThread
();
/// Working method which should be overridden
/// Working method which should be overridden
virtual
void
SAL_CALL
run
();
virtual
void
execute
();
public
:
public
:
enum
Status
enum
Status
...
@@ -113,8 +115,6 @@ class OfficeIPCThread : public osl::Thread
...
@@ -113,8 +115,6 @@ class OfficeIPCThread : public osl::Thread
IPC_STATUS_BOOTSTRAP_ERROR
IPC_STATUS_BOOTSTRAP_ERROR
};
};
virtual
~
OfficeIPCThread
();
// controlling pipe communication during shutdown
// controlling pipe communication during shutdown
static
void
SetDowning
();
static
void
SetDowning
();
static
void
EnableRequests
(
bool
i_bEnable
=
true
);
static
void
EnableRequests
(
bool
i_bEnable
=
true
);
...
@@ -126,7 +126,9 @@ class OfficeIPCThread : public osl::Thread
...
@@ -126,7 +126,9 @@ class OfficeIPCThread : public osl::Thread
static
Status
EnableOfficeIPCThread
();
static
Status
EnableOfficeIPCThread
();
static
void
DisableOfficeIPCThread
();
static
void
DisableOfficeIPCThread
();
// start dispatching events...
// start dispatching events...
static
void
SetReady
(
OfficeIPCThread
*
pThread
=
NULL
);
static
void
SetReady
(
rtl
::
Reference
<
OfficeIPCThread
>
const
&
pThread
=
rtl
::
Reference
<
OfficeIPCThread
>
());
bool
AreRequestsEnabled
()
const
{
return
mbRequestsEnabled
&&
!
mbDowning
;
}
bool
AreRequestsEnabled
()
const
{
return
mbRequestsEnabled
&&
!
mbDowning
;
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment