unload the IMCs and IMVs using dlclose()
This commit is contained in:
@@ -37,6 +37,11 @@ struct private_tnc_imc_t {
|
|||||||
*/
|
*/
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle of loaded IMC
|
||||||
|
*/
|
||||||
|
void *handle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of loaded IMC
|
* ID of loaded IMC
|
||||||
*/
|
*/
|
||||||
@@ -121,8 +126,9 @@ METHOD(imc_t, type_supported, bool,
|
|||||||
METHOD(imc_t, destroy, void,
|
METHOD(imc_t, destroy, void,
|
||||||
private_tnc_imc_t *this)
|
private_tnc_imc_t *this)
|
||||||
{
|
{
|
||||||
free(this->name);
|
dlclose(this->handle);
|
||||||
free(this->supported_types);
|
free(this->supported_types);
|
||||||
|
free(this->name);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +138,6 @@ METHOD(imc_t, destroy, void,
|
|||||||
imc_t* tnc_imc_create(char* name, char *filename)
|
imc_t* tnc_imc_create(char* name, char *filename)
|
||||||
{
|
{
|
||||||
private_tnc_imc_t *this;
|
private_tnc_imc_t *this;
|
||||||
void *handle;
|
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
@@ -145,8 +150,8 @@ imc_t* tnc_imc_create(char* name, char *filename)
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
handle = dlopen(filename, RTLD_NOW);
|
this->handle = dlopen(filename, RTLD_NOW);
|
||||||
if (handle == NULL)
|
if (!this->handle)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "IMC '%s' failed to load from '%s': %s",
|
DBG1(DBG_TNC, "IMC '%s' failed to load from '%s': %s",
|
||||||
name, filename, dlerror());
|
name, filename, dlerror());
|
||||||
@@ -154,39 +159,42 @@ imc_t* tnc_imc_create(char* name, char *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we do not store or free dlopen() handles, leak_detective requires
|
/* we do not store or free dlopen() this->handles, leak_detective requires
|
||||||
* the modules to keep loaded until leak report */
|
* the modules to keep loaded until leak report */
|
||||||
|
|
||||||
this->public.initialize = dlsym(handle, "TNC_IMC_Initialize");
|
this->public.initialize = dlsym(this->handle, "TNC_IMC_Initialize");
|
||||||
if (!this->public.initialize)
|
if (!this->public.initialize)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMC_Initialize in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMC_Initialize in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
this->public.notify_connection_change =
|
this->public.notify_connection_change =
|
||||||
dlsym(handle, "TNC_IMC_NotifyConnectionChange");
|
dlsym(this->handle, "TNC_IMC_NotifyConnectionChange");
|
||||||
this->public.begin_handshake = dlsym(handle, "TNC_IMC_BeginHandshake");
|
this->public.begin_handshake = dlsym(this->handle, "TNC_IMC_BeginHandshake");
|
||||||
if (!this->public.begin_handshake)
|
if (!this->public.begin_handshake)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMC_BeginHandshake in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMC_BeginHandshake in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
this->public.receive_message =
|
this->public.receive_message =
|
||||||
dlsym(handle, "TNC_IMC_ReceiveMessage");
|
dlsym(this->handle, "TNC_IMC_ReceiveMessage");
|
||||||
this->public.batch_ending =
|
this->public.batch_ending =
|
||||||
dlsym(handle, "TNC_IMC_BatchEnding");
|
dlsym(this->handle, "TNC_IMC_BatchEnding");
|
||||||
this->public.terminate =
|
this->public.terminate =
|
||||||
dlsym(handle, "TNC_IMC_Terminate");
|
dlsym(this->handle, "TNC_IMC_Terminate");
|
||||||
this->public.provide_bind_function =
|
this->public.provide_bind_function =
|
||||||
dlsym(handle, "TNC_IMC_ProvideBindFunction");
|
dlsym(this->handle, "TNC_IMC_ProvideBindFunction");
|
||||||
if (!this->public.provide_bind_function)
|
if (!this->public.provide_bind_function)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMC_ProvideBindFunction in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMC_ProvideBindFunction in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ struct private_tnc_imv_t {
|
|||||||
*/
|
*/
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle of loaded IMV
|
||||||
|
*/
|
||||||
|
void *handle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of loaded IMV
|
* ID of loaded IMV
|
||||||
*/
|
*/
|
||||||
@@ -121,8 +126,9 @@ METHOD(imv_t, type_supported, bool,
|
|||||||
METHOD(imv_t, destroy, void,
|
METHOD(imv_t, destroy, void,
|
||||||
private_tnc_imv_t *this)
|
private_tnc_imv_t *this)
|
||||||
{
|
{
|
||||||
free(this->name);
|
dlclose(this->handle);
|
||||||
free(this->supported_types);
|
free(this->supported_types);
|
||||||
|
free(this->name);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +138,6 @@ METHOD(imv_t, destroy, void,
|
|||||||
imv_t* tnc_imv_create(char *name, char *filename)
|
imv_t* tnc_imv_create(char *name, char *filename)
|
||||||
{
|
{
|
||||||
private_tnc_imv_t *this;
|
private_tnc_imv_t *this;
|
||||||
void *handle;
|
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
@@ -145,8 +150,8 @@ imv_t* tnc_imv_create(char *name, char *filename)
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
handle = dlopen(filename, RTLD_NOW);
|
this->handle = dlopen(filename, RTLD_NOW);
|
||||||
if (handle == NULL)
|
if (!this->handle)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "IMV '%s' failed to load from '%s': %s",
|
DBG1(DBG_TNC, "IMV '%s' failed to load from '%s': %s",
|
||||||
name, filename, dlerror());
|
name, filename, dlerror());
|
||||||
@@ -154,40 +159,40 @@ imv_t* tnc_imv_create(char *name, char *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we do not store or free dlopen() handles, leak_detective requires
|
this->public.initialize = dlsym(this->handle, "TNC_IMV_Initialize");
|
||||||
* the modules to keep loaded until leak report */
|
|
||||||
|
|
||||||
this->public.initialize = dlsym(handle, "TNC_IMV_Initialize");
|
|
||||||
if (!this->public.initialize)
|
if (!this->public.initialize)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMV_Initialize in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMV_Initialize in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
this->public.notify_connection_change =
|
this->public.notify_connection_change =
|
||||||
dlsym(handle, "TNC_IMV_NotifyConnectionChange");
|
dlsym(this->handle, "TNC_IMV_NotifyConnectionChange");
|
||||||
this->public.solicit_recommendation =
|
this->public.solicit_recommendation =
|
||||||
dlsym(handle, "TNC_IMV_SolicitRecommendation");
|
dlsym(this->handle, "TNC_IMV_SolicitRecommendation");
|
||||||
if (!this->public.solicit_recommendation)
|
if (!this->public.solicit_recommendation)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMV_SolicitRecommendation in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMV_SolicitRecommendation in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
this->public.receive_message =
|
this->public.receive_message =
|
||||||
dlsym(handle, "TNC_IMV_ReceiveMessage");
|
dlsym(this->handle, "TNC_IMV_ReceiveMessage");
|
||||||
this->public.batch_ending =
|
this->public.batch_ending =
|
||||||
dlsym(handle, "TNC_IMV_BatchEnding");
|
dlsym(this->handle, "TNC_IMV_BatchEnding");
|
||||||
this->public.terminate =
|
this->public.terminate =
|
||||||
dlsym(handle, "TNC_IMV_Terminate");
|
dlsym(this->handle, "TNC_IMV_Terminate");
|
||||||
this->public.provide_bind_function =
|
this->public.provide_bind_function =
|
||||||
dlsym(handle, "TNC_IMV_ProvideBindFunction");
|
dlsym(this->handle, "TNC_IMV_ProvideBindFunction");
|
||||||
if (!this->public.provide_bind_function)
|
if (!this->public.provide_bind_function)
|
||||||
{
|
{
|
||||||
DBG1(DBG_TNC, "could not resolve TNC_IMV_ProvideBindFunction in %s: %s\n",
|
DBG1(DBG_TNC, "could not resolve TNC_IMV_ProvideBindFunction in %s: %s\n",
|
||||||
filename, dlerror());
|
filename, dlerror());
|
||||||
|
dlclose(this->handle);
|
||||||
free(this);
|
free(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user