25 #include "dbus-internals.h"
26 #include "dbus-watch.h"
27 #include "dbus-list.h"
57 _dbus_watch_get_enabled (
DBusWatch *watch)
63 _dbus_watch_get_oom_last_time (
DBusWatch *watch)
69 _dbus_watch_set_oom_last_time (
DBusWatch *watch,
97 #define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE)
107 watch->
flags = flags;
146 if (_dbus_pollable_is_valid (watch->
fd))
147 _dbus_warn (
"this watch should have been invalidated");
171 _dbus_pollable_invalidate (&watch->
fd);
186 unsigned int *condition)
237 if (watch_list ==
NULL)
262 #ifdef DBUS_ENABLE_VERBOSE_MODE
264 watch_flags_to_string (
int flags)
266 const char *watch_type;
270 watch_type =
"readwrite";
271 else if (flags & DBUS_WATCH_READABLE)
273 else if (flags & DBUS_WATCH_WRITABLE)
274 watch_type =
"write";
276 watch_type =
"not read or write";
304 if (add_function !=
NULL)
313 #ifdef DBUS_ENABLE_VERBOSE_MODE
316 _dbus_verbose (
"Adding a %s watch on fd %" DBUS_POLLABLE_FORMAT
" using newly-set add watch function\n",
318 _dbus_pollable_printable (watch->
fd));
321 if (!(* add_function) (link->
data, data))
327 while (link2 != link)
331 #ifdef DBUS_ENABLE_VERBOSE_MODE
334 _dbus_verbose (
"Removing watch on fd %" DBUS_POLLABLE_FORMAT
" using newly-set remove function because initial add failed\n",
335 _dbus_pollable_printable (watch2->
fd));
338 (* remove_function) (link2->
data, data);
354 _dbus_verbose (
"Removing all pre-existing watches\n");
392 _dbus_verbose (
"Adding watch on fd %" DBUS_POLLABLE_FORMAT
"\n",
393 _dbus_pollable_printable (watch->
fd));
423 _dbus_verbose (
"Removing watch on fd %" DBUS_POLLABLE_FORMAT
"\n",
424 _dbus_pollable_printable (watch->
fd));
455 _dbus_verbose (
"Toggling watch %p on fd %" DBUS_POLLABLE_FORMAT
" to %d\n",
457 _dbus_pollable_printable (watch->
fd),
546 _dbus_return_val_if_fail (watch !=
NULL, -1);
567 _dbus_return_val_if_fail (watch !=
NULL, -1);
596 _dbus_return_val_if_fail (watch !=
NULL, -1);
601 return _dbus_socket_get_int (watch->
fd);
606 _dbus_watch_get_socket (
DBusWatch *watch)
622 _dbus_watch_get_pollable (
DBusWatch *watch)
645 _dbus_return_val_if_fail (watch !=
NULL, 0);
661 _dbus_return_val_if_fail (watch !=
NULL,
NULL);
682 _dbus_return_if_fail (watch !=
NULL);
684 _dbus_verbose (
"Setting watch fd %" DBUS_POLLABLE_FORMAT
" data to data = %p function = %p from data = %p function = %p\n",
685 _dbus_pollable_printable (watch->
fd),
705 _dbus_return_val_if_fail (watch !=
NULL,
FALSE);
737 _dbus_return_val_if_fail (watch !=
NULL,
FALSE);
739 #ifndef DBUS_DISABLE_CHECKS
740 if (!_dbus_pollable_is_valid (watch->
fd) || watch->
flags == 0)
747 _dbus_return_val_if_fail (_dbus_pollable_is_valid (watch->
fd) ,
TRUE);
753 _dbus_verbose (
"After sanitization, watch flags on fd %" DBUS_POLLABLE_FORMAT
" were 0\n",
754 _dbus_pollable_printable (watch->
fd));
758 return (* watch->
handler) (watch, flags,