Kaydet (Commit) a883b6b1 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Improve logging

Change-Id: Iabfe272e95e4f3517f3072dd6c36b8889c2fdbd1
üst f0aef9b3
...@@ -37,14 +37,13 @@ typedef struct _oslConditionImpl ...@@ -37,14 +37,13 @@ typedef struct _oslConditionImpl
oslCondition SAL_CALL osl_createCondition() oslCondition SAL_CALL osl_createCondition()
{ {
oslConditionImpl* pCond; oslConditionImpl* pCond;
int nRet=0; int nRet=0;
pCond = (oslConditionImpl*) malloc(sizeof(oslConditionImpl)); pCond = (oslConditionImpl*) malloc(sizeof(oslConditionImpl));
if ( pCond == 0 ) if ( pCond == 0 )
{ {
SAL_WARN("sal.osl", "std::bad_alloc in C");
return 0; return 0;
} }
...@@ -54,10 +53,7 @@ oslCondition SAL_CALL osl_createCondition() ...@@ -54,10 +53,7 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_cond_init(&pCond->m_Condition, PTHREAD_CONDATTR_DEFAULT); nRet = pthread_cond_init(&pCond->m_Condition, PTHREAD_CONDATTR_DEFAULT);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "pthread_cond_init failed: " << strerror(nRet) );
"sal.osl",
"pthread_cond_init failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
free(pCond); free(pCond);
return 0; return 0;
...@@ -66,21 +62,17 @@ oslCondition SAL_CALL osl_createCondition() ...@@ -66,21 +62,17 @@ oslCondition SAL_CALL osl_createCondition()
nRet = pthread_mutex_init(&pCond->m_Lock, PTHREAD_MUTEXATTR_DEFAULT); nRet = pthread_mutex_init(&pCond->m_Lock, PTHREAD_MUTEXATTR_DEFAULT);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "pthread_mutex_init failed: " << strerror(nRet) );
"sal.osl",
"pthread_mutex_init failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
nRet = pthread_cond_destroy(&pCond->m_Condition); nRet = pthread_cond_destroy(&pCond->m_Condition);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_cond_destroy failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_cond_destroy failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
free(pCond); free(pCond);
pCond = 0; pCond = 0;
} }
SAL_INFO( "osl.condition", "osl_createCondition(): " << pCond );
return (oslCondition)pCond; return (oslCondition)pCond;
} }
...@@ -88,20 +80,16 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition) ...@@ -88,20 +80,16 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
{ {
oslConditionImpl* pCond; 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); int nRet = pthread_cond_destroy(&pCond->m_Condition);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_cond_destroy failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_cond_destroy failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
nRet = pthread_mutex_destroy(&pCond->m_Lock); nRet = pthread_mutex_destroy(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "pthread_mutex_destroy failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_destroy failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
free(Condition); free(Condition);
} }
...@@ -125,10 +113,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition) ...@@ -125,10 +113,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock); nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
"sal.osl",
"pthread_mutex_lock failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
return sal_False; return sal_False;
} }
...@@ -136,10 +121,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition) ...@@ -136,10 +121,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_cond_broadcast(&pCond->m_Condition); nRet = pthread_cond_broadcast(&pCond->m_Condition);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_cond_broadcast failed: " << strerror(nRet) );
"sal.osl",
"pthread_cond_broadcast failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
// try to unlock the mutex // try to unlock the mutex
pthread_mutex_unlock(&pCond->m_Lock); pthread_mutex_unlock(&pCond->m_Lock);
return sal_False; return sal_False;
...@@ -148,13 +130,12 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition) ...@@ -148,13 +130,12 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_setCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
"sal.osl",
"pthread_mutex_unlock failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
return sal_False; return sal_False;
} }
SAL_INFO( "osl.condition", "osl_setCondition(" << pCond << ")" );
return sal_True; return sal_True;
} }
...@@ -176,10 +157,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition) ...@@ -176,10 +157,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_lock(&pCond->m_Lock); nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_resetCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
"sal.osl",
"pthread_mutex_lock failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
return sal_False; return sal_False;
} }
...@@ -188,12 +166,12 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition) ...@@ -188,12 +166,12 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_resetCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
"sal.osl", "pthread_mutex_unlock failed, errno " << nRet <<", \""
<< strerror(nRet) << '"');
return sal_False; return sal_False;
} }
SAL_INFO( "osl.condition", "osl_resetCondition(" << pCond << ")" );
return sal_True; return sal_True;
} }
...@@ -206,6 +184,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -206,6 +184,8 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
assert(Condition); assert(Condition);
pCond = (oslConditionImpl*)Condition; pCond = (oslConditionImpl*)Condition;
SAL_INFO( "osl.condition", "osl_waitCondition(" << pCond << ")" );
if ( pCond == 0 ) if ( pCond == 0 )
{ {
return osl_cond_result_error; return osl_cond_result_error;
...@@ -214,9 +194,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -214,9 +194,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_mutex_lock(&pCond->m_Lock); nRet = pthread_mutex_lock(&pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
"sal.osl", "pthread_mutex_lock failed, errno " << nRet <<", \""
<< strerror(nRet) << '"');
return osl_cond_result_error; return osl_cond_result_error;
} }
...@@ -242,10 +220,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -242,10 +220,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{ {
Result = osl_cond_result_timeout; Result = osl_cond_result_timeout;
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_unlock failed, errno " << nRet
<< ", \"" << strerror(nRet) << '"');
return Result; return Result;
} }
...@@ -253,10 +228,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -253,10 +228,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
{ {
Result = osl_cond_result_error; Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_unlock failed, errno " << nRet
<< ", \"" << strerror(nRet) << '"');
return Result; return Result;
} }
} }
...@@ -271,16 +243,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -271,16 +243,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
nRet = pthread_cond_wait(&pCond->m_Condition, &pCond->m_Lock); nRet = pthread_cond_wait(&pCond->m_Condition, &pCond->m_Lock);
if ( nRet != 0 ) if ( nRet != 0 )
{ {
SAL_WARN( SAL_WARN( "osl.condition", "osl_waitCondition(" << pCond << "): pthread_cond_wait failed: " << strerror(nRet) );
"sal.osl",
"pthread_cond_wait failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
Result = osl_cond_result_error; Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_unlock failed, errno " << nRet << ", \""
<< strerror(nRet) << '"');
return Result; return Result;
} }
...@@ -288,10 +254,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time ...@@ -288,10 +254,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
} }
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_waitCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_unlock failed, errno " << nRet << ", \"" SAL_INFO( "osl.condition", "osl_waitCondition(" << pCond << "): " << (Result == osl_cond_result_ok ? "OK" : "ERROR") );
<< strerror(nRet) << '"');
return Result; return Result;
} }
...@@ -311,18 +276,14 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition) ...@@ -311,18 +276,14 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
} }
nRet = pthread_mutex_lock(&pCond->m_Lock); nRet = pthread_mutex_lock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_checkCondition(" << pCond << "): pthread_mutex_lock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_lock failed, errno " << nRet << ", \"" << strerror(nRet)
<< '"');
State = pCond->m_State; State = pCond->m_State;
nRet = pthread_mutex_unlock(&pCond->m_Lock); nRet = pthread_mutex_unlock(&pCond->m_Lock);
SAL_WARN_IF( SAL_WARN_IF( nRet != 0, "osl.condition", "osl_checkCondition(" << pCond << "): pthread_mutex_unlock failed: " << strerror(nRet) );
nRet != 0, "sal.osl",
"pthread_mutex_unlock failed, errno " << nRet << ", \"" SAL_INFO( "osl.condition", "osl_checkCondition(" << pCond << "): " << (State ? "YES" : "NO") );
<< strerror(nRet) << '"');
return State; return State;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment