Hi Gary, ack, code review only/Thanks HansN
On 2019-06-20 04:13, Gary Lee wrote: > In handle_event_in_failover_state(), we iterate through > queue_evt in a while loop, but process_event() can insert > items into the queue inside the loop, and we may end > up never exiting the while loop. > --- > src/amf/amfd/main.cc | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/src/amf/amfd/main.cc b/src/amf/amfd/main.cc > index 50daa59..e3d0957 100644 > --- a/src/amf/amfd/main.cc > +++ b/src/amf/amfd/main.cc > @@ -406,12 +406,18 @@ static void handle_event_in_failover_state(AVD_EVT > *evt) { > > /* Dequeue, all the messages from the queue > and process them now */ > - > - while (!cb->evt_queue.empty()) { > + auto size_before_loop = cb->evt_queue.size(); > + std::queue<AVD_EVT_QUEUE *>::size_type count = 0; > + while (count < size_before_loop) { > + // note: process_event() may insert items into > + // the queue, so terminate loop when we have > + // processed all the original elements > + // to avoid infinite loop > AVD_EVT_QUEUE *queue_evt = cb->evt_queue.front(); > cb->evt_queue.pop(); > process_event(cb, queue_evt->evt); > delete queue_evt; > + ++count; > } > > /* Walk through all the nodes to check if any of the nodes state is _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel