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/common/pkcs11_lib.c

    r255 r269  
    618618  void *module_handle; 
    619619  CK_FUNCTION_LIST_PTR fl; 
     620  int should_finalize; 
    620621  slot_t *slots; 
    621622  CK_ULONG slot_count; 
     
    715716  if (flag) rv = h->fl->C_Initialize((CK_VOID_PTR) &initArgs); 
    716717  else      rv = h->fl->C_Initialize(NULL); 
    717   if (rv != CKR_OK) { 
     718  if (rv == CKR_OK) 
     719    h->should_finalize = 1; 
     720  else if (rv != CKR_CRYPTOKI_ALREADY_INITIALIZED) { 
    718721    set_error("C_Initialize() failed: %x", rv); 
    719722    return -1; 
     
    804807  /* finalise pkcs #11 module */ 
    805808  if (h->fl != NULL) 
    806     h->fl->C_Finalize(NULL); 
     809    if (h->should_finalize) 
     810      h->fl->C_Finalize(NULL); 
    807811  /* unload the module */ 
    808812  if (h->module_handle != NULL) 
Note: See TracChangeset for help on using the changeset viewer.