- if (loop->watch_count > N_STACK_DESCRIPTORS)
- {
- fds = dbus_new0 (DBusPollFD, loop->watch_count);
-
- while (fds == NULL)
- {
- _dbus_wait_for_memory ();
- fds = dbus_new0 (DBusPollFD, loop->watch_count);
- }
- }
- else
- {
- fds = stack_fds;
- }
-
- /* fill our array of fds and watches */
- n_fds = 0;
- _dbus_hash_iter_init (loop->watches, &hash_iter);
-
- while (_dbus_hash_iter_next (&hash_iter))
- {
- DBusList **watches;
- unsigned int flags;
- int fd;
-
- fd = _dbus_hash_iter_get_int_key (&hash_iter);
- watches = _dbus_hash_iter_get_value (&hash_iter);
- flags = 0;
-
- for (link = _dbus_list_get_first_link (watches);
- link != NULL;
- link = _dbus_list_get_next_link (watches, link))
- {
- DBusWatch *watch = link->data;
-
- if (_dbus_watch_get_oom_last_time (watch))
- {
- /* we skip this one this time, but reenable it next time,
- * and have a timeout on this iteration
- */
- _dbus_watch_set_oom_last_time (watch, FALSE);
- oom_watch_pending = TRUE;
-
- retval = TRUE; /* return TRUE here to keep the loop going,
- * since we don't know the watch is inactive
- */
-
-#if MAINLOOP_SPEW
- _dbus_verbose (" skipping watch on fd %d as it was out of memory last time\n",
- fd);
-#endif
- }
- else if (dbus_watch_get_enabled (watch))
- {
- flags |= dbus_watch_get_flags (watch);
- }
- }
-
- if (flags != 0)
- {
- fds[n_fds].fd = fd;
- fds[n_fds].revents = 0;
- fds[n_fds].events = watch_flags_to_poll_events (flags);
-
-#if MAINLOOP_SPEW
- _dbus_verbose (" polling watch on fd %d %s\n",
- loop->fds[loop->n_fds].fd, watch_flags_to_string (flags));
-#endif
-
- n_fds += 1;
- }
- else
- {
-#if MAINLOOP_SPEW
- _dbus_verbose (" skipping disabled watch on fd %d %s\n",
- fd,
- watch_flags_to_string (dbus_watch_get_flags (watch)));
-#endif
- }
- }
-