{
Callback callback;
DBusWatch *watch;
- /* last watch handle failed due to OOM */
- unsigned int last_iteration_oom : 1;
} WatchCallback;
typedef struct
return NULL;
cb->watch = watch;
- cb->last_iteration_oom = FALSE;
cb->callback.refcount = 1;
cb->callback.type = CALLBACK_WATCH;
wcb = WATCH_CALLBACK (cb);
fd = dbus_watch_get_socket (wcb->watch);
- if (wcb->last_iteration_oom)
+ if (_dbus_watch_get_oom_last_time (wcb->watch))
{
/* we skip this one this time, but reenable it next time,
* and have a timeout on this iteration
*/
- wcb->last_iteration_oom = FALSE;
+ _dbus_watch_set_oom_last_time (wcb->watch, FALSE);
oom_watch_pending = TRUE;
retval = TRUE; /* return TRUE here to keep the loop going,
oom = !dbus_watch_handle (wcb->watch, condition);
if (oom)
- wcb->last_iteration_oom = TRUE;
+ {
+ _dbus_watch_set_oom_last_time (wcb->watch, TRUE);
+ }
#if MAINLOOP_SPEW
- _dbus_verbose (" Invoked watch, oom = %d\n",
- wcb->last_iteration_oom);
+ _dbus_verbose (" Invoked watch, oom = %d\n", oom);
#endif
retval = TRUE;
void *data; /**< Application data. */
DBusFreeFunction free_data_function; /**< Free the application data. */
unsigned int enabled : 1; /**< Whether it's enabled. */
+ unsigned int oom_last_time : 1; /**< Whether it was OOM last time. */
};
dbus_bool_t
return watch->enabled;
}
+dbus_bool_t
+_dbus_watch_get_oom_last_time (DBusWatch *watch)
+{
+ return watch->oom_last_time;
+}
+
+void
+_dbus_watch_set_oom_last_time (DBusWatch *watch,
+ dbus_bool_t oom)
+{
+ watch->oom_last_time = oom;
+}
+
/**
* Creates a new DBusWatch. Used to add a file descriptor to be polled
* by a main loop.