- gdb_event *event_ptr, *prev_ptr;
- event_handler_func *proc;
- int fd;
-
- /* First let's see if there are any asynchronous event handlers that
- are ready. These would be the result of invoking any of the
- signal handlers. */
-
- if (check_async_ready ())
- {
- invoke_async_signal_handler ();
- return 1;
- }
-
- /* Look in the event queue to find an event that is ready
- to be processed. */
-
- for (event_ptr = event_queue.first_event; event_ptr != NULL;
- event_ptr = event_ptr->next_event)
- {
- /* Call the handler for the event. */
-
- proc = event_ptr->proc;
- fd = event_ptr->fd;
-
- /* Let's get rid of the event from the event queue. We need to
- do this now because while processing the event, the proc
- function could end up calling 'error' and therefore jump out
- to the caller of this function, gdb_do_one_event. In that
- case, we would have on the event queue an event wich has been
- processed, but not deleted. */
-
- if (event_queue.first_event == event_ptr)
- {
- event_queue.first_event = event_ptr->next_event;
- if (event_ptr->next_event == NULL)
- event_queue.last_event = NULL;
- }
- else
- {
- prev_ptr = event_queue.first_event;
- while (prev_ptr->next_event != event_ptr)
- prev_ptr = prev_ptr->next_event;
-
- prev_ptr->next_event = event_ptr->next_event;
- if (event_ptr->next_event == NULL)
- event_queue.last_event = prev_ptr;
- }
- xfree (event_ptr);