[Libreoffice-commits] core.git: sal/osl
Tor Lillqvist
tml at collabora.com
Tue Feb 3 04:20:52 PST 2015
sal/osl/unx/conditn.cxx | 111 +++++++++++++++---------------------------------
1 file changed, 36 insertions(+), 75 deletions(-)
New commits:
commit a883b6b13b67898accdc1ffe3fd9e770612352b1
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Feb 3 13:17:09 2015 +0100
Improve logging
Change-Id: Iabfe272e95e4f3517f3072dd6c36b8889c2fdbd1
diff --git a/sal/osl/unx/conditn.cxx b/sal/osl/unx/conditn.cxx
index 91d80d7..42aa05e 100644
--- a/sal/osl/unx/conditn.cxx
+++ b/sal/osl/unx/conditn.cxx
@@ -37,14 +37,13 @@ typedef struct _oslConditionImpl
oslCondition SAL_CALL osl_createCondition()
{
- oslConditionImpl* pCond;
+ oslConditionImpl* pCond;
int nRet=0;
pCond = (oslConditionImpl*) malloc(sizeof(oslConditionImpl));
if ( pCond == 0 )
{
- SAL_WARN("sal.osl", "std::bad_alloc in C");
return 0;
}
@@ -54,10 +53,7 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_cond_init(&pCond->m_Condition, PTHREAD_CONDATTR_DEFAULT);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_cond_init failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "pthread_cond_init failed: " << strerror(nRet) );
free(pCond);
return 0;
@@ -66,21 +62,17 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_mutex_init(&pCond->m_Lock, PTHREAD_MUTEXATTR_DEFAULT);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_mutex_init failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "pthread_mutex_init failed: " << strerror(nRet) );
nRet = pthread_cond_destroy(&pCond->m_Condition);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_cond_destroy failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_cond_destroy failed: " << strerror(nRet) );
free(pCond);
pCond = 0;
}
+ SAL_INFO( "osl.condition", "osl_createCondition(): " << pCond );
+
return (oslCondition)pCond;
}
@@ -88,20 +80,16 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
{
oslConditionImpl* pCond;
- if ( Condition )
- {
- pCond = (oslConditionImpl*)Condition;
+ pCond = (oslConditionImpl*)Condition;
+
+ SAL_INFO( "osl.condition", "osl_destroyCondition(" << pCond << ")" );
+ if ( pCond )
+ {
int nRet = pthread_cond_destroy(&pCond->m_Condition);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_cond_destroy failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_cond_destroy failed: " << strerror(nRet) );
nRet = pthread_mutex_destroy(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_destroy failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_mutex_destroy failed: " << strerror(nRet) );
free(Condition);
}
@@ -125,10 +113,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_mutex_lock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
return sal_False;
}
@@ -136,10 +121,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_cond_broadcast(&pCond->m_Condition);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_cond_broadcast failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_cond_broadcast failed: " << strerror(nRet) );
// try to unlock the mutex
pthread_mutex_unlock(&pCond->m_Lock);
return sal_False;
@@ -148,13 +130,12 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
return sal_False;
}
+ SAL_INFO( "osl.condition", "osl_setCondition(" << pCond << ")" );
+
return sal_True;
}
@@ -176,10 +157,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_mutex_lock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_resetCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
return sal_False;
}
@@ -188,12 +166,12 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl", "pthread_mutex_unlock failed, errno " << nRet <<", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_resetCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
return sal_False;
}
+ SAL_INFO( "osl.condition", "osl_resetCondition(" << pCond << ")" );
+
return sal_True;
}
@@ -206,6 +184,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
assert(Condition);
pCond = (oslConditionImpl*)Condition;
+ SAL_INFO( "osl.condition", "osl_waitCondition(" << pCond << ")" );
+
if ( pCond == 0 )
{
return osl_cond_result_error;
@@ -214,9 +194,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl", "pthread_mutex_lock failed, errno " << nRet <<", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
return osl_cond_result_error;
}
@@ -242,10 +220,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{
Result = osl_cond_result_timeout;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet
- << ", \"" << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
return Result;
}
@@ -253,10 +228,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet
- << ", \"" << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
return Result;
}
}
@@ -271,16 +243,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_cond_wait(&pCond->m_Condition, &pCond->m_Lock);
if ( nRet != 0 )
{
- SAL_WARN(
- "sal.osl",
- "pthread_cond_wait failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN( "osl.condition", "osl_waitCondition(" << pCond << "): pthread_cond_wait failed: " << strerror(nRet) );
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
return Result;
}
@@ -288,10 +254,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
}
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
+
+ SAL_INFO( "osl.condition", "osl_waitCondition(" << pCond << "): " << (Result == osl_cond_result_ok ? "OK" : "ERROR") );
return Result;
}
@@ -311,18 +276,14 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
}
nRet = pthread_mutex_lock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_lock failed, errno " << nRet << ", \"" << strerror(nRet)
- << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_checkCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
State = pCond->m_State;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
- SAL_WARN_IF(
- nRet != 0, "sal.osl",
- "pthread_mutex_unlock failed, errno " << nRet << ", \""
- << strerror(nRet) << '"');
+ SAL_WARN_IF( nRet != 0, "osl.condition", "osl_checkCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
+
+ SAL_INFO( "osl.condition", "osl_checkCondition(" << pCond << "): " << (State ? "YES" : "NO") );
return State;
}
More information about the Libreoffice-commits
mailing list