lock the set_message_types() method for imvs
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
#include <threading/mutex.h>
|
||||||
|
|
||||||
typedef struct private_tnc_imv_t private_tnc_imv_t;
|
typedef struct private_tnc_imv_t private_tnc_imv_t;
|
||||||
|
|
||||||
@@ -61,6 +62,11 @@ struct private_tnc_imv_t {
|
|||||||
* Number of supported message types
|
* Number of supported message types
|
||||||
*/
|
*/
|
||||||
TNC_UInt32 type_count;
|
TNC_UInt32 type_count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mutex to lock the imv_t object
|
||||||
|
*/
|
||||||
|
mutex_t *mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
METHOD(imv_t, set_id, void,
|
METHOD(imv_t, set_id, void,
|
||||||
@@ -90,6 +96,9 @@ METHOD(imv_t, set_message_types, void,
|
|||||||
int len = sizeof(buf);
|
int len = sizeof(buf);
|
||||||
int written;
|
int written;
|
||||||
|
|
||||||
|
/* lock the imv_t instance */
|
||||||
|
this->mutex->lock(this->mutex);
|
||||||
|
|
||||||
/* Free an existing MessageType list */
|
/* Free an existing MessageType list */
|
||||||
free(this->supported_types);
|
free(this->supported_types);
|
||||||
this->supported_types = NULL;
|
this->supported_types = NULL;
|
||||||
@@ -118,6 +127,9 @@ METHOD(imv_t, set_message_types, void,
|
|||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
DBG2(DBG_TNC, "IMV %u supports %u message types:%s",
|
DBG2(DBG_TNC, "IMV %u supports %u message types:%s",
|
||||||
this->id, type_count, buf);
|
this->id, type_count, buf);
|
||||||
|
|
||||||
|
/* lock the imv_t instance */
|
||||||
|
this->mutex->unlock(this->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(imv_t, type_supported, bool,
|
METHOD(imv_t, type_supported, bool,
|
||||||
@@ -151,6 +163,7 @@ METHOD(imv_t, destroy, void,
|
|||||||
private_tnc_imv_t *this)
|
private_tnc_imv_t *this)
|
||||||
{
|
{
|
||||||
dlclose(this->handle);
|
dlclose(this->handle);
|
||||||
|
this->mutex->destroy(this->mutex);
|
||||||
free(this->supported_types);
|
free(this->supported_types);
|
||||||
free(this->name);
|
free(this->name);
|
||||||
free(this->path);
|
free(this->path);
|
||||||
@@ -175,6 +188,7 @@ imv_t* tnc_imv_create(char *name, char *path)
|
|||||||
},
|
},
|
||||||
.name = name,
|
.name = name,
|
||||||
.path = path,
|
.path = path,
|
||||||
|
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||||
);
|
);
|
||||||
|
|
||||||
this->handle = dlopen(path, RTLD_LAZY);
|
this->handle = dlopen(path, RTLD_LAZY);
|
||||||
|
|||||||
Reference in New Issue
Block a user