mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-06 00:00:47 -04:00
If adding an IMC/IMV fails, terminate() it only if it has been initialize()d
This commit is contained in:
parent
fd885fd390
commit
be18ee8123
@ -51,10 +51,9 @@ METHOD(imc_manager_t, add, bool,
|
||||
{
|
||||
TNC_Version version;
|
||||
|
||||
/* Initialize the module */
|
||||
imc->set_id(imc, this->next_imc_id);
|
||||
if (imc->initialize(imc->get_id(imc), TNC_IFIMC_VERSION_1,
|
||||
TNC_IFIMC_VERSION_1, &version) != TNC_RESULT_SUCCESS)
|
||||
TNC_IFIMC_VERSION_1, &version) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMC \"%s\" failed to initialize", imc->get_name(imc));
|
||||
return FALSE;
|
||||
@ -62,15 +61,18 @@ METHOD(imc_manager_t, add, bool,
|
||||
this->imcs->insert_last(this->imcs, imc);
|
||||
this->next_imc_id++;
|
||||
|
||||
if (imc->provide_bind_function(imc->get_id(imc), TNC_TNCC_BindFunction)
|
||||
!= TNC_RESULT_SUCCESS)
|
||||
if (imc->provide_bind_function(imc->get_id(imc),
|
||||
TNC_TNCC_BindFunction) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
if (imc->terminate)
|
||||
{
|
||||
imc->terminate(imc->get_id(imc));
|
||||
}
|
||||
DBG1(DBG_TNC, "IMC \"%s\" failed to obtain bind function",
|
||||
imc->get_name(imc));
|
||||
imc->get_name(imc));
|
||||
this->imcs->remove_last(this->imcs, (void**)&imc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -107,12 +109,6 @@ METHOD(imc_manager_t, load, bool,
|
||||
}
|
||||
if (!add(this, imc))
|
||||
{
|
||||
if (imc->terminate &&
|
||||
imc->terminate(imc->get_id(imc)) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMC \"%s\" not terminated successfully",
|
||||
imc->get_name(imc));
|
||||
}
|
||||
imc->destroy(imc);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -67,10 +67,9 @@ METHOD(imv_manager_t, add, bool,
|
||||
{
|
||||
TNC_Version version;
|
||||
|
||||
/* Initialize the IMV module */
|
||||
imv->set_id(imv, this->next_imv_id);
|
||||
if (imv->initialize(imv->get_id(imv), TNC_IFIMV_VERSION_1,
|
||||
TNC_IFIMV_VERSION_1, &version) != TNC_RESULT_SUCCESS)
|
||||
TNC_IFIMV_VERSION_1, &version) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMV \"%s\" failed to initialize", imv->get_name(imv));
|
||||
return FALSE;
|
||||
@ -78,15 +77,18 @@ METHOD(imv_manager_t, add, bool,
|
||||
this->imvs->insert_last(this->imvs, imv);
|
||||
this->next_imv_id++;
|
||||
|
||||
if (imv->provide_bind_function(imv->get_id(imv), TNC_TNCS_BindFunction)
|
||||
!= TNC_RESULT_SUCCESS)
|
||||
if (imv->provide_bind_function(imv->get_id(imv),
|
||||
TNC_TNCS_BindFunction) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMV \"%s\" could failed to obtain bind function",
|
||||
imv->get_name(imv));
|
||||
if (imv->terminate)
|
||||
{
|
||||
imv->terminate(imv->get_id(imv));
|
||||
}
|
||||
DBG1(DBG_TNC, "IMV \"%s\" failed to obtain bind function",
|
||||
imv->get_name(imv));
|
||||
this->imvs->remove_last(this->imvs, (void**)&imv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -123,12 +125,6 @@ METHOD(imv_manager_t, load, bool,
|
||||
}
|
||||
if (!add(this, imv))
|
||||
{
|
||||
if (imv->terminate &&
|
||||
imv->terminate(imv->get_id(imv)) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
DBG1(DBG_TNC, "IMV \"%s\" not terminated successfully",
|
||||
imv->get_name(imv));
|
||||
}
|
||||
imv->destroy(imv);
|
||||
return FALSE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user