From e8fc08dc8ea4e26e7d994bcfb24a7ad93fe8ca0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 2 Apr 2013 14:31:22 +0000 Subject: [PATCH] still nothing, undo and more log; refs #25 --- src/openssl-engine.hxx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/openssl-engine.hxx b/src/openssl-engine.hxx index 5b40e0c..5dc4e83 100644 --- a/src/openssl-engine.hxx +++ b/src/openssl-engine.hxx @@ -79,9 +79,11 @@ namespace openssl { } virtual ~Engine() { OPENSSL_LOG("log"); - // removed EngineMapper::destroy because of crash: - // https://dev.marc.waeckerlin.org/projects/libpcscxx/ticket/25 - //OPENSSL_CHECK(ENGINE_free(_e)); + if (_e) { + OPENSSL_LOG("free the engine"); + OPENSSL_CHECK(ENGINE_free(_e)); + _e = 0; + } } virtual const char* id() = 0; virtual const char* name() = 0; @@ -147,10 +149,8 @@ namespace openssl { _map[e->_e] = e; OPENSSL_CHECK(ENGINE_set_id(e->_e, e->id())); OPENSSL_CHECK(ENGINE_set_name(e->_e, e->name())); - // removed EngineMapper::destroy because of crash: - // https://dev.marc.waeckerlin.org/projects/libpcscxx/ticket/25 - //OPENSSL_CHECK(ENGINE_set_destroy_function - // (e->_e, EngineMapper::destroy)); + OPENSSL_CHECK(ENGINE_set_destroy_function + (e->_e, EngineMapper::destroy)); OPENSSL_CHECK(ENGINE_set_init_function(e->_e, EngineMapper::init)); OPENSSL_CHECK(ENGINE_set_finish_function(e->_e, EngineMapper::finish)); OPENSSL_CHECK(ENGINE_set_ctrl_function(e->_e, EngineMapper::ctrl)); @@ -173,10 +173,15 @@ namespace openssl { static void remove(Engine *e) { OPENSSL_LOG("log"); - OPENSSL_CHECK(ENGINE_remove(e->_e)); - OPENSSL_CHECK(ENGINE_finish(e->_e)); - _map.erase(e->_e); - delete e; + if (e) { + OPENSSL_LOG("call remove: e->_e = "<<((void*)e->_e)); + OPENSSL_CHECK(ENGINE_remove(e->_e)); + OPENSSL_LOG("call finish"); + OPENSSL_CHECK(ENGINE_finish(e->_e)); + OPENSSL_LOG("erase from map"); + _map.erase(e->_e); + delete e; e=0; + } } private: @@ -193,6 +198,7 @@ namespace openssl { static int finish(ENGINE* e) { OPENSSL_LOG("log"); Map::iterator it(_map.find(e)); + OPENSSL_LOG("finish: "<<(it!=_map.end()?"true":"false")); return it!=_map.end()?it->second->finish():0; } static int ctrl(ENGINE* e, int cmd, long i, void* p, void(*f)()) {