- {
- /* If an event falls in the woods, and there is no handler to hear it,
- * does it make any sound?
- * I don't know either, so lets try recycling the event */
- clib_fifo_add1 (evt->event_index_fifo, ev_idx);
- evt->recycle_event = 1;
- clib_spinlock_unlock (&evt->handlers_lockp);
- goto unlock;
- }
- handler = pool_elt_at_index (evt->vce_event_handlers, p[0]);
- handler->ev_idx = ev_idx;
-
- clib_spinlock_unlock (&evt->handlers_lockp);
-
- (handler->handler_fn)(handler);
-
- unlock:
- pthread_mutex_unlock (&(evt->generator_lock));
+ {
+ /* If an event falls in the woods, and there is no handler to hear it,
+ * does it make any sound?
+ * I don't know either, so lets biff the event */
+ pool_put(evt->vce_events, ev);
+ VCE_EVENTS_UNLOCK ();
+ VCE_HANDLERS_UNLOCK ();
+ pthread_mutex_unlock (&(evt->generator_lock));
+ }
+ else
+ {
+ u32 evt_recycle = ev->recycle;
+ handler = pool_elt_at_index (evt->vce_event_handlers, p[0]);
+ handler->ev_idx = ev_idx;
+ ev->recycle = 0;
+
+ VCE_EVENTS_UNLOCK ();
+ VCE_HANDLERS_UNLOCK ();
+ pthread_mutex_unlock (&(evt->generator_lock));
+
+ (handler->handler_fn)(handler);
+
+ VCE_EVENTS_LOCK ();
+ ev = vce_get_event_from_index (evt, ev_idx);
+ recycle_count += (!evt_recycle && ev && ev->recycle) ? 1 : 0;
+ VCE_EVENTS_UNLOCK ();
+ }
+
+ pthread_mutex_lock (&(evt->generator_lock));