From: Tobias Brunner Date: Fri, 27 May 2016 08:17:53 +0000 (+0200) Subject: unit-tests: Make sure to flush the IKE_SA manager before destroying the sender X-Git-Tag: 5.5.0dr1~4^2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=735bd4ca14adb752ce6ad6f0b2dbc40173710f19;p=thirdparty%2Fstrongswan.git unit-tests: Make sure to flush the IKE_SA manager before destroying the sender As the static plugin that creates and destroys the default sender was not initialized because of the missing socket the daemon won't destroy our sender. Test cases will eventually have to flush the IKE_SA manager to satisfy the leak detective. However, in case of a test failure and if there are IKE_SAs in the manager the daemon will flush the SAs when deinitializing, which will cause deletes to get sent. This crashes if the sender is already destroyed. --- diff --git a/src/libcharon/tests/utils/exchange_test_helper.c b/src/libcharon/tests/utils/exchange_test_helper.c index c535dfb38c..ab562271f6 100644 --- a/src/libcharon/tests/utils/exchange_test_helper.c +++ b/src/libcharon/tests/utils/exchange_test_helper.c @@ -354,7 +354,9 @@ void exchange_test_helper_deinit() } lib->credmgr->remove_set(lib->credmgr, &this->creds->set); this->creds->destroy(this->creds); - /* can't let charon do it as it happens too late */ + /* flush SAs before destroying the sender (in case of test failures) */ + charon->ike_sa_manager->flush(charon->ike_sa_manager); + /* charon won't destroy this as it didn't initialize the original sender */ charon->sender->destroy(charon->sender); charon->sender = NULL; array_destroy(this->listeners);