Use a separate interface for loggers.
The new interface does not allow loggers to unregister themselves from the bus. This allows us to use a rwlock_t for them. The latter also means that loggers can now be called concurrently by multiple threads.
This commit is contained in:
@@ -41,7 +41,7 @@ struct private_android_logger_t {
|
||||
};
|
||||
|
||||
|
||||
METHOD(listener_t, log_, bool,
|
||||
METHOD(logger_t, log_, void,
|
||||
private_android_logger_t *this, debug_t group, level_t level,
|
||||
int thread, ike_sa_t* ike_sa, char *format, va_list args)
|
||||
{
|
||||
@@ -64,8 +64,6 @@ METHOD(listener_t, log_, bool,
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
/* always stay registered */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(android_logger_t, destroy, void,
|
||||
@@ -83,7 +81,7 @@ android_logger_t *android_logger_create()
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.listener = {
|
||||
.logger = {
|
||||
.log = _log_,
|
||||
},
|
||||
.destroy = _destroy,
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct android_logger_t android_logger_t;
|
||||
struct android_logger_t {
|
||||
|
||||
/**
|
||||
* Implements bus_listener_t interface
|
||||
* Implements logger_t interface
|
||||
*/
|
||||
listener_t listener;
|
||||
logger_t logger;
|
||||
|
||||
/**
|
||||
* Destroy the logger.
|
||||
|
||||
@@ -68,7 +68,7 @@ METHOD(plugin_t, destroy, void,
|
||||
hydra->attributes->remove_handler(hydra->attributes,
|
||||
&this->handler->handler);
|
||||
lib->credmgr->remove_set(lib->credmgr, &this->creds->set);
|
||||
charon->bus->remove_listener(charon->bus, &this->logger->listener);
|
||||
charon->bus->remove_logger(charon->bus, &this->logger->logger);
|
||||
this->creds->destroy(this->creds);
|
||||
this->handler->destroy(this->handler);
|
||||
this->logger->destroy(this->logger);
|
||||
@@ -98,7 +98,7 @@ plugin_t *android_plugin_create()
|
||||
this->service = android_service_create(this->creds);
|
||||
this->handler = android_handler_create(this->service != NULL);
|
||||
|
||||
charon->bus->add_listener(charon->bus, &this->logger->listener);
|
||||
charon->bus->add_logger(charon->bus, &this->logger->logger);
|
||||
lib->credmgr->add_set(lib->credmgr, &this->creds->set);
|
||||
hydra->attributes->add_handler(hydra->attributes, &this->handler->handler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user