Ignore:
Timestamp:
05/15/07 07:18:24 (5 years ago)
Author:
ludovic.rousseau
Message:

C_Initalize should be called after each fork

The pkcs11_eventmgr first C_Initialize then becomes a daemon... The
PKCS#11 standard states that after fork the user must call C_Initialize
again, in order to allow proper library initialization at new process.

Also, don't quit on major errors... try to reinitialize.

Closes ticket #14. Thanks to Alon Bar-Lev for the patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tools/pkcs11_eventmgr.c

    r243 r269  
    7474  void *module_handle; 
    7575  CK_FUNCTION_LIST_PTR fl; 
     76  int should_finalize; 
    7677  slot_t *slots; 
    7778  CK_ULONG slot_count; 
     
    510511    } 
    511512 
    512     /* open pkcs11 sesion */ 
    513     DBG("initialising pkcs #11 module..."); 
    514     rv = ph->fl->C_Initialize(NULL); 
    515     if (rv != 0) { 
    516         release_pkcs11_module(ph); 
    517         DBG1("C_Initialize() failed: %d", rv); 
    518         return 1; 
    519     } 
    520  
    521513    /* put my self into background if flag is set */ 
    522514    if (daemonize) { 
     
    529521        } 
    530522    } 
     523 
     524    /* open pkcs11 sesion */ 
     525    DBG("initialising pkcs #11 module..."); 
     526    rv = ph->fl->C_Initialize(NULL); 
     527    if (rv != 0) { 
     528        release_pkcs11_module(ph); 
     529        if (ctx) 
     530          scconf_free(ctx); 
     531        DBG1("C_Initialize() failed: %d", rv); 
     532        return 1; 
     533    } 
     534    ph->should_finalize = 1; 
    531535 
    532536    /*  
     
    551555           if (new_state == CARD_ERROR) { 
    552556                DBG("Error trying to get a token"); 
     557                rv = ph->fl->C_Finalize(NULL); 
     558                rv = ph->fl->C_Initialize(NULL); 
    553559                break; 
    554560           } 
Note: See TracChangeset for help on using the changeset viewer.