NSS Library Init: Difference between revisions

Update proposed names. Add questions of clarification
m (trivial proofreading fixes.)
(Update proposed names. Add questions of clarification)
Line 35: Line 35:
== Proposal ==
== Proposal ==


Provide a new NSS call to initialize NSS: NSS_LibraryInit(). This call would be made by system libraries that use NSS. NSS_LibraryInit() would take the same parameters as NSS_Init(), but it will return a context that the library would save. This context would be passed to NSS_LibraryShutdown(). The semantics and interaction of these initialization functions are as follows:


Provide a new NSS call to initialize NSS: NSS_Library_Init(). This call would be made by system libraries that use NSS. NSS_Library_Init() would take the same parameters as NSS_Init(), but it will return a context the library would save. This context would be passed to NSS_Library_Shutdown(). The semantics and interaction of these initialization functions are as follows:
1. Multiple NSS_LibraryInit() calls are allowed. Each call will get it's own context. NSS will keep a count of NSS_LibraryInit calls. (why? --[[User:Nelsonb|MisterTLS]] 22:00, 1 September 2009 (UTC)) If the database referenced by a given NSS library init call has not been opened, NSS_LibraryInit() will open that database in a new slot.


1. Multiple NSS_Library_Init() calls are allowed. Each call will get it's own context. NSS will keep a count of NSS_Library_Init calls. If the database referenced by a given NSS library init call has not been opened, NSS_Library_Init() will open that database in a new slot.
2. NSS_Init will continue to function as it does today with the following exception: while multple NSS_Init calls are idempotent, NSS_Init() called after one or more NSS_LibraryInit() calls will function just as NSS_LibraryInit() does with respect opening new databases. In addition, the 'main' database from NSS_Init() will be the database returned by PK11_GetInternalPrivateKeyDB().


2. NSS_Init will continue to function as it does today with the following exception: while multple NSS_Init calls are idempotent, NSS_Init() called after one or more NSS_Library_Init() calls will function just as NSS_Library_Init() does with respect opening new databases. In addition, the 'main' database from NSS_Init() will be the database returned by PK11_GetInternalPrivateKeyDB().
3. NSS_LibraryShutdown() can be called once per context. If NSS_LibraryShutdown is called a second time on a context, an error is returned. NSS_LibraryShutdown() will shut down NSS if there are no more active contexts returned by NSS_LibraryInit and NSS_Init() has not been called.


3. NSS_Library_Shutdown() can be called once per context. If NSS_Library_Shutdown is called a second time on a context an error is returned. NSS_Library_Shutdown() will shutdown NSS if there are no more active contexts returned by NSS_Library_Init and NSS_Init() has not been called.
4. An application that initialized NSS with NSS_Init() can call NSS_LibraryShutdown() with NULL. This will close out the NSS_Init() call, but will only shutdown NSS if all the active contexts are also closed. (What if NSS_Init has been called multiple times? --[[User:Nelsonb|MisterTLS]] 22:00, 1 September 2009 (UTC) )
 
4. An application that initialized NSS with NSS_Init() can call NSS_Library_Shutdown() with NULL. This will close out the NSS_Init() call, but will only shutdown NSS if all the active contexts are also closed.


5. NSS_Shutdown() will operate as it does today. NSS will completely shutdown, active contexts will be closed.
5. NSS_Shutdown() will operate as it does today. NSS will completely shutdown, active contexts will be closed.
Line 53: Line 52:
  typedef struct NSSInitContextStr NSSInitContext; /* opaque */
  typedef struct NSSInitContextStr NSSInitContext; /* opaque */


  NSSInitContext *NSS_Library_Init(const char *configdir,
  NSSInitContext *NSS_LibraryInit(const char *configdir,
         const char *certPrefix, const char *keyPrefix,
         const char *certPrefix, const char *keyPrefix,
         const char *secmodName, PRUint32 flags);
         const char *secmodName, PRUint32 flags);


  SECStatus NSS_Library_Shutdown(NSSInitContext *);
  SECStatus NSS_LibraryShutdown(NSSInitContext *);
106

edits