Changeset 2832

Show
Ignore:
Timestamp:
02/05/06 19:35:55 (3 years ago)
Author:
nils
Message:

sc_mutex_destroy should have a return value

Location:
trunk/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/libopensc/card.c

    r2829 r2832  
    8888        if (card->algorithms != NULL) 
    8989                free(card->algorithms); 
    90         if (card->mutex != NULL) 
    91                 sc_mutex_destroy(card->ctx, card->mutex); 
     90        if (card->mutex != NULL) { 
     91                int r = sc_mutex_destroy(card->ctx, card->mutex); 
     92                if (r != SC_SUCCESS) 
     93                        sc_error(card->ctx, "unable to destroy mutex\n"); 
     94        } 
    9295        sc_mem_clear(card, sizeof(*card)); 
    9396        free(card); 
  • trunk/src/libopensc/ctbcs.c

    r2829 r2832  
    159159        sc_apdu_t apdu; 
    160160        struct sc_card_operations ops; 
    161         int r; 
     161        int r, s; 
    162162 
    163163        switch (data->cmd) { 
     
    186186 
    187187        r = sc_transmit_apdu(card, &apdu); 
    188         sc_mutex_destroy(reader->ctx, card->mutex); 
     188        s = sc_mutex_destroy(reader->ctx, card->mutex); 
     189        if (s != SC_SUCCESS) { 
     190                sc_error(reader->ctx, "unable to destroy mutex\n"); 
     191                return s; 
     192        } 
    189193        SC_TEST_RET(card->ctx, r, "APDU transmit failed"); 
    190194         
  • trunk/src/libopensc/ctx.c

    r2831 r2832  
    747747                        _sc_free_atr(ctx, drv); 
    748748        } 
     749        if (ctx->preferred_language != NULL) 
     750                free(ctx->preferred_language); 
     751        if (ctx->mutex != NULL) { 
     752                int r = sc_mutex_destroy(ctx, ctx->mutex); 
     753                if (r != SC_SUCCESS) { 
     754                        sc_error(ctx, "unable to destroy mutex\n"); 
     755                        return r; 
     756                } 
     757        } 
     758        if (ctx->conf != NULL) 
     759                scconf_free(ctx->conf); 
    749760        if (ctx->debug_file && ctx->debug_file != stdout) 
    750761                fclose(ctx->debug_file); 
    751762        if (ctx->error_file && ctx->error_file != stderr) 
    752763                fclose(ctx->error_file); 
    753         if (ctx->preferred_language != NULL) 
    754                 free(ctx->preferred_language); 
    755         if (ctx->conf != NULL) 
    756                 scconf_free(ctx->conf); 
    757         if (ctx->mutex != NULL) 
    758                 sc_mutex_destroy(ctx, ctx->mutex); 
    759764        if (ctx->app_name != NULL) 
    760765                free(ctx->app_name); 
  • trunk/src/libopensc/internal.h

    r2831 r2832  
    149149 * @param  ctx    sc_context_t object with the thread context 
    150150 * @param  mutex  mutex object to be destroyed 
     151 * @return SC_SUCCESS on success and an error code otherwise 
    151152 */ 
    152 void sc_mutex_destroy(const sc_context_t *ctx, void *mutex); 
     153int sc_mutex_destroy(const sc_context_t *ctx, void *mutex); 
    153154/** 
    154155 * Returns a unique id for every thread. 
  • trunk/src/libopensc/opensc.h

    r2831 r2832  
    630630        int (*unlock_mutex)(void *); 
    631631        /** destroys a mutex object */ 
    632         void (*destroy_mutex)(void *); 
     632        int (*destroy_mutex)(void *); 
    633633        /** returns unique identifier for the thread (can be NULL) */ 
    634634        unsigned long (*thread_id)(void); 
  • trunk/src/libopensc/sc.c

    r2829 r2832  
    706706} 
    707707 
    708 void sc_mutex_destroy(const sc_context_t *ctx, void *mutex) 
    709 { 
    710         if (ctx == NULL || ctx->thread_ctx == NULL || 
    711             ctx->thread_ctx->destroy_mutex == NULL) 
    712                 return; 
    713         ctx->thread_ctx->destroy_mutex(mutex); 
     708int sc_mutex_destroy(const sc_context_t *ctx, void *mutex) 
     709{ 
     710        if (ctx == NULL) 
     711                return SC_ERROR_INVALID_ARGUMENTS; 
     712        if (ctx->thread_ctx != NULL && ctx->thread_ctx->destroy_mutex != NULL) 
     713                return ctx->thread_ctx->destroy_mutex(mutex); 
     714        else 
     715                return SC_SUCCESS; 
    714716} 
    715717 
  • trunk/src/pkcs11/pkcs11-global.c

    r2829 r2832  
    152152} 
    153153 
    154 static void sc_destroy_mutex(void *m) 
     154static int sc_destroy_mutex(void *m) 
    155155{ 
    156156        if (_locking == NULL) 
    157                 return; 
    158         _locking->DestroyMutex(m); 
     157                return SC_SUCCESS; 
     158        if (_locking->DestroyMutex(m) == CKR_OK) 
     159                return SC_SUCCESS; 
     160        else 
     161                return SC_ERROR_INTERNAL; 
    159162} 
    160163