Remove obsolete bus_t.listen() method.
This commit is contained in:
@@ -142,64 +142,6 @@ struct cleanup_data_t {
|
|||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* thread_cleanup_t handler to remove a listener
|
|
||||||
*/
|
|
||||||
static void listener_cleanup(cleanup_data_t *data)
|
|
||||||
{
|
|
||||||
data->this->listeners->remove(data->this->listeners, data->entry, NULL);
|
|
||||||
entry_destroy(data->entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(bus_t, listen_, bool,
|
|
||||||
private_bus_t *this, listener_t *listener, job_t *job, u_int timeout)
|
|
||||||
{
|
|
||||||
bool old, timed_out = FALSE;
|
|
||||||
cleanup_data_t data;
|
|
||||||
timeval_t tv, add;
|
|
||||||
|
|
||||||
if (timeout)
|
|
||||||
{
|
|
||||||
add.tv_sec = timeout / 1000;
|
|
||||||
add.tv_usec = (timeout - (add.tv_sec * 1000)) * 1000;
|
|
||||||
time_monotonic(&tv);
|
|
||||||
timeradd(&tv, &add, &tv);
|
|
||||||
}
|
|
||||||
|
|
||||||
data.this = this;
|
|
||||||
data.entry = entry_create(listener, TRUE);
|
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
|
||||||
this->listeners->insert_last(this->listeners, data.entry);
|
|
||||||
lib->processor->queue_job(lib->processor, job);
|
|
||||||
thread_cleanup_push((thread_cleanup_t)this->mutex->unlock, this->mutex);
|
|
||||||
thread_cleanup_push((thread_cleanup_t)listener_cleanup, &data);
|
|
||||||
old = thread_cancelability(TRUE);
|
|
||||||
while (data.entry->blocker)
|
|
||||||
{
|
|
||||||
if (timeout)
|
|
||||||
{
|
|
||||||
if (data.entry->condvar->timed_wait_abs(data.entry->condvar,
|
|
||||||
this->mutex, tv))
|
|
||||||
{
|
|
||||||
this->listeners->remove(this->listeners, data.entry, NULL);
|
|
||||||
timed_out = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data.entry->condvar->wait(data.entry->condvar, this->mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
thread_cancelability(old);
|
|
||||||
thread_cleanup_pop(FALSE);
|
|
||||||
/* unlock mutex */
|
|
||||||
thread_cleanup_pop(TRUE);
|
|
||||||
entry_destroy(data.entry);
|
|
||||||
return timed_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHOD(bus_t, set_sa, void,
|
METHOD(bus_t, set_sa, void,
|
||||||
private_bus_t *this, ike_sa_t *ike_sa)
|
private_bus_t *this, ike_sa_t *ike_sa)
|
||||||
{
|
{
|
||||||
@@ -715,7 +657,6 @@ bus_t *bus_create()
|
|||||||
.public = {
|
.public = {
|
||||||
.add_listener = _add_listener,
|
.add_listener = _add_listener,
|
||||||
.remove_listener = _remove_listener,
|
.remove_listener = _remove_listener,
|
||||||
.listen = _listen_,
|
|
||||||
.set_sa = _set_sa,
|
.set_sa = _set_sa,
|
||||||
.get_sa = _get_sa,
|
.get_sa = _get_sa,
|
||||||
.log = _log_,
|
.log = _log_,
|
||||||
|
|||||||
+7
-23
@@ -141,27 +141,11 @@ struct bus_t {
|
|||||||
*/
|
*/
|
||||||
void (*remove_listener) (bus_t *this, listener_t *listener);
|
void (*remove_listener) (bus_t *this, listener_t *listener);
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a listener and block the calling thread.
|
|
||||||
*
|
|
||||||
* This call registers a listener and blocks the calling thread until
|
|
||||||
* its listeners function returns FALSE. This allows to wait for certain
|
|
||||||
* events. The associated job is executed after the listener has been
|
|
||||||
* registered: This allows to listen on events we initiate with the job,
|
|
||||||
* without missing any events to job may fire.
|
|
||||||
*
|
|
||||||
* @param listener listener to register
|
|
||||||
* @param job job to execute asynchronously when registered, or NULL
|
|
||||||
* @param timeout max timeout in ms to listen for events, 0 to disable
|
|
||||||
* @return TRUE if timed out
|
|
||||||
*/
|
|
||||||
bool (*listen)(bus_t *this, listener_t *listener, job_t *job, u_int timeout);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the IKE_SA the calling thread is using.
|
* Set the IKE_SA the calling thread is using.
|
||||||
*
|
*
|
||||||
* To associate an received log message to an IKE_SA without passing it as
|
* To associate a received log message with an IKE_SA without passing it as
|
||||||
* parameter each time, the thread registers the currenlty used IKE_SA
|
* parameter each time, the thread registers the currently used IKE_SA
|
||||||
* during check-out. Before check-in, the thread unregisters the IKE_SA.
|
* during check-out. Before check-in, the thread unregisters the IKE_SA.
|
||||||
* This IKE_SA is stored per-thread, so each thread has its own IKE_SA
|
* This IKE_SA is stored per-thread, so each thread has its own IKE_SA
|
||||||
* registered.
|
* registered.
|
||||||
@@ -183,9 +167,8 @@ struct bus_t {
|
|||||||
/**
|
/**
|
||||||
* Send a log message to the bus.
|
* Send a log message to the bus.
|
||||||
*
|
*
|
||||||
* The signal specifies the type of the event occurred. The format string
|
* The format string specifies an additional informational or error
|
||||||
* specifies an additional informational or error message with a
|
* message with a printf() like variable argument list.
|
||||||
* printf() like variable argument list.
|
|
||||||
* Use the DBG() macros.
|
* Use the DBG() macros.
|
||||||
*
|
*
|
||||||
* @param group debugging group
|
* @param group debugging group
|
||||||
@@ -198,7 +181,7 @@ struct bus_t {
|
|||||||
/**
|
/**
|
||||||
* Send a log message to the bus using va_list arguments.
|
* Send a log message to the bus using va_list arguments.
|
||||||
*
|
*
|
||||||
* Same as bus_t.signal(), but uses va_list argument list.
|
* Same as bus_t.log(), but uses va_list argument list.
|
||||||
*
|
*
|
||||||
* @param group kind of the signal (up, down, rekeyed, ...)
|
* @param group kind of the signal (up, down, rekeyed, ...)
|
||||||
* @param level verbosity level of the signal
|
* @param level verbosity level of the signal
|
||||||
@@ -212,7 +195,7 @@ struct bus_t {
|
|||||||
* Raise an alert over the bus.
|
* Raise an alert over the bus.
|
||||||
*
|
*
|
||||||
* @param alert kind of alert
|
* @param alert kind of alert
|
||||||
* @param ... alert specific attributes
|
* @param ... alert specific arguments
|
||||||
*/
|
*/
|
||||||
void (*alert)(bus_t *this, alert_t alert, ...);
|
void (*alert)(bus_t *this, alert_t alert, ...);
|
||||||
|
|
||||||
@@ -278,6 +261,7 @@ struct bus_t {
|
|||||||
void (*ike_keys)(bus_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
void (*ike_keys)(bus_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
|
||||||
chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r,
|
chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r,
|
||||||
ike_sa_t *rekey, shared_key_t *shared);
|
ike_sa_t *rekey, shared_key_t *shared);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CHILD_SA keymat hook.
|
* CHILD_SA keymat hook.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user