Some fixes to the reference-counting in ENGINE code. First, there were a
few statements equivalent to "ENGINE_add(ENGINE_openssl())" etc. The inner call to ENGINE_openssl() (as with other functions like it) orphans a structural reference count. Second, the ENGINE_cleanup() function also needs to clean up the functional reference counts held internally as the list of "defaults" (ie. as used when RSA_new() requires an appropriate ENGINE reference). So ENGINE_clear_defaults() was created and is called from within ENGINE_cleanup(). Third, some of the existing code was logically broken in its treatment of reference counts and locking (my fault), so the necessary bits have been restructured and tidied up. To test this stuff, compiling with ENGINE_REF_COUNT_DEBUG will cause every reference count change (both structural and functional) to log a message to 'stderr'. Using with "openssl engine" for example shows this in action quite well as the 'engine' sub-command cleans up after itself properly. Also replaced some spaces with tabs.
This commit is contained in:
@@ -62,12 +62,14 @@
|
||||
|
||||
static int engine_add(ENGINE *e)
|
||||
{
|
||||
int toret = 1;
|
||||
if (!ENGINE_by_id(ENGINE_get_id(e)))
|
||||
{
|
||||
(void)ERR_get_error();
|
||||
return ENGINE_add(e);
|
||||
toret = ENGINE_add(e);
|
||||
}
|
||||
return 1;
|
||||
ENGINE_free(e);
|
||||
return toret;
|
||||
}
|
||||
|
||||
void ENGINE_load_cswift(void)
|
||||
|
Reference in New Issue
Block a user