Changeset 125 in libcf


Ignore:
Timestamp:
06/12/13 13:44:25 (11 years ago)
Author:
cheese
Message:

#1 fix mutex bugs

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_debug.c

    r124 r125  
    391391    ASSERT_CTX (ctx);
    392392
    393     CF_Mutex_Lock (&ctx->mutex);
     393    CF_Mutex_Lock (ctx->mutex);
    394394    CF_Debug_CallStackPush (gDebugSingleCtx, file, func, line);
    395     CF_Mutex_Unlock (&ctx->mutex);
     395    CF_Mutex_Unlock (ctx->mutex);
    396396
    397397    return CF_OK;
     
    412412    ASSERT_CTX (ctx);
    413413
    414     CF_Mutex_Lock (&ctx->mutex);
     414    CF_Mutex_Lock (ctx->mutex);
    415415    CF_Debug_CallStackPop (gDebugSingleCtx, NULL);
    416     CF_Mutex_Unlock (&ctx->mutex);
     416    CF_Mutex_Unlock (ctx->mutex);
    417417
    418418    return CF_OK;
  • trunk/src/cf_log.c

    r123 r125  
    5151    if (gLogArray.ctxPool[__mapid] == NULL) \
    5252        return CF_ERROR_LOG_NOT_MAPPED_ID
    53 
    54 #define LOCK_LOG_CTX(__ctx)             CF_Mutex_Lock (__ctx->mutex)
    55 #define UNLOCK_LOG_CTX(__ctx)           CF_Mutex_Unlock (__ctx->mutex)
    5653
    5754#define LOG_BUFFER_DEFAULT_SIZE         128 * 1024
     
    314311    ASSERT_CTX (ctx);
    315312
    316     LOCK_LOG_CTX (context);
     313    CF_Mutex_Lock (context->mutex);
    317314//  va_start (valist, fmt);
    318315
     
    324321
    325322//  va_end (valist);
    326     UNLOCK_LOG_CTX (context);
     323    CF_Mutex_Unlock (context->mutex);
    327324
    328325    return CF_OK;
     
    343340    ASSERT_CTX (ctx);
    344341
    345     LOCK_LOG_CTX (context);
     342    CF_Mutex_Lock (context->mutex);
    346343    CF_Log_Local_Flush (context);
    347     UNLOCK_LOG_CTX (context);
     344    CF_Mutex_Unlock (context->mutex);
    348345
    349346    return CF_OK;
  • trunk/test/log.c

    r122 r125  
    1919    int th = 0;
    2020   
    21     if (CF_Mutex_Lock (&globalMutex) < 0) { // for critical section
     21    if (CF_Mutex_Lock (globalMutex) < 0) { // for critical section
    2222        // error
    2323    }
    2424    th = cnt++;
    25     if (CF_Mutex_Unlock (&globalMutex) < 0) { // for critical section
     25    if (CF_Mutex_Unlock (globalMutex) < 0) { // for critical section
    2626        // error
    2727    }
  • trunk/test/thread.c

    r122 r125  
    1010
    1111int worker (void * arg) {
    12     if (CF_Mutex_Lock (&globalMutex) < 0) { // for critical section
     12    if (CF_Mutex_Lock (globalMutex) < 0) { // for critical section
    1313        // error
    1414    }
     
    1616    fprintf (stderr, "here is critical section !\n");
    1717
    18     if (CF_Mutex_Unlock (&globalMutex) < 0) { // for critical section
     18    if (CF_Mutex_Unlock (globalMutex) < 0) { // for critical section
    1919        // error
    2020    }
Note: See TracChangeset for help on using the changeset viewer.