29
29
// -----------------------------------------------------------------------------
30
30
#include " listeners_manager.h"
31
31
#include " sp_main.h"
32
+ #include " utilities/sp_util.h"
32
33
33
34
34
35
// -----------------------------------------------------------------------------
@@ -171,12 +172,7 @@ SpewRetval_t SP_SpewOutput( SpewType_t spewType, const tchar *pMsg )
171
172
{
172
173
static CServerOutputListenerManager *pManager = GetOnServerOutputListenerManager ();
173
174
174
- bool block = false ;
175
- EnterCriticalSection (&pManager->m_pCriticalSection ); {
176
- block = pManager->CallCallbacks ((MessageSeverity)spewType, pMsg);
177
- } LeaveCriticalSection (&pManager->m_pCriticalSection );
178
-
179
- if (!block && pManager->m_pOldSpewOutputFunc ) {
175
+ if (!pManager->CallCallbacks ((MessageSeverity)spewType, pMsg) && pManager->m_pOldSpewOutputFunc ) {
180
176
return pManager->m_pOldSpewOutputFunc (spewType, pMsg);
181
177
}
182
178
@@ -190,12 +186,7 @@ class SPLoggingListener: public ILoggingListener
190
186
{
191
187
static CServerOutputListenerManager *pManager = GetOnServerOutputListenerManager ();
192
188
193
- bool block = false ;
194
- EnterCriticalSection (&pManager->m_pCriticalSection ); {
195
- block = pManager->CallCallbacks ((MessageSeverity)pContext->m_Severity , pMessage);
196
- } LeaveCriticalSection (&pManager->m_pCriticalSection );
197
-
198
- if (!block)
189
+ if (!pManager->CallCallbacks ((MessageSeverity)pContext->m_Severity , pMessage))
199
190
{
200
191
// Restore the old logging state before SP has been loaded
201
192
LoggingSystem_PopLoggingState (false );
@@ -230,7 +221,6 @@ CServerOutputListenerManager::CServerOutputListenerManager()
230
221
:m_pOldSpewOutputFunc(NULL )
231
222
#endif
232
223
{
233
- InitializeCriticalSection (&m_pCriticalSection);
234
224
}
235
225
236
226
@@ -280,15 +270,18 @@ void CServerOutputListenerManager::Finalize()
280
270
bool CServerOutputListenerManager::CallCallbacks (MessageSeverity severity, const tchar *pMsg)
281
271
{
282
272
bool block = false ;
283
- FOR_EACH_VEC (m_vecCallables, i) {
284
- BEGIN_BOOST_PY ()
285
- object return_value = m_vecCallables[i](severity, pMsg);
286
-
287
- if (!return_value.is_none () && extract<OutputReturn>(return_value) == OUTPUT_BLOCK)
288
- block = true ;
289
-
290
- END_BOOST_PY_NORET ()
291
- }
273
+ m_Mutex.Lock (); {
274
+ FOR_EACH_VEC (m_vecCallables, i) {
275
+ try {
276
+ object return_value = m_vecCallables[i](severity, pMsg);
277
+
278
+ if (!return_value.is_none () && extract<OutputReturn>(return_value) == OUTPUT_BLOCK)
279
+ block = true ;
280
+ } catch (...) {
281
+ PrintCurrentException (false );
282
+ }
283
+ }
284
+ } m_Mutex.Unlock ();
292
285
return block;
293
286
}
294
287
0 commit comments