static dbus_bool_t add_server_watch (DBusWatch *watch, void *data) { ServerData *context = data; return _dbus_loop_add_watch (context->loop, watch); }
static dbus_bool_t add_watch (DBusWatch *watch, void *data) { CData *cd = data; return _dbus_loop_add_watch (cd->loop, watch); }
static dbus_bool_t add_server_watch (DBusWatch *watch, void *data) { DBusServer *server = data; BusContext *context; context = server_get_context (server); return _dbus_loop_add_watch (context->loop, watch); }
static int _init_kqueue (BusContext *context) { int ret = 0; if (kq < 0) { kq = kqueue (); if (kq < 0) { _dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno)); goto out; } loop = bus_context_get_loop (context); watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, _handle_kqueue_watch, NULL, NULL); if (watch == NULL) { _dbus_warn ("Unable to create kqueue watch\n"); close (kq); kq = -1; goto out; } if (!_dbus_loop_add_watch (loop, watch)) { _dbus_warn ("Unable to add reload watch to main loop"); _dbus_watch_invalidate (watch); _dbus_watch_unref (watch); watch = NULL; close (kq); kq = -1; goto out; } } ret = 1; out: return ret; }
static void setup_reload_pipe (DBusLoop *loop) { DBusError error; DBusWatch *watch; dbus_error_init (&error); if (!_dbus_full_duplex_pipe (&reload_pipe[0], &reload_pipe[1], TRUE, &error)) { _dbus_warn ("Unable to create reload pipe: %s\n", error.message); dbus_error_free (&error); exit (1); } _dbus_fd_set_close_on_exec (reload_pipe[0]); _dbus_fd_set_close_on_exec (reload_pipe[1]); watch = _dbus_watch_new (reload_pipe[RELOAD_READ_END], DBUS_WATCH_READABLE, TRUE, handle_reload_watch, NULL, NULL); if (watch == NULL) { _dbus_warn ("Unable to create reload watch: %s\n", error.message); dbus_error_free (&error); exit (1); } if (!_dbus_loop_add_watch (loop, watch, reload_watch_callback, NULL, NULL)) { _dbus_warn ("Unable to add reload watch to main loop: %s\n", error.message); dbus_error_free (&error); exit (1); } }
static void setup_reload_pipe (DBusLoop *loop) { DBusError error; DBusWatch *watch; dbus_error_init (&error); if (!_dbus_socketpair (&reload_pipe[0], &reload_pipe[1], TRUE, &error)) { _dbus_warn ("Unable to create reload pipe: %s\n", error.message); dbus_error_free (&error); exit (1); } watch = _dbus_watch_new (reload_pipe[RELOAD_READ_END], DBUS_WATCH_READABLE, TRUE, handle_reload_watch, NULL, NULL); if (watch == NULL) { _dbus_warn ("Unable to create reload watch: %s\n", error.message); dbus_error_free (&error); exit (1); } if (!_dbus_loop_add_watch (loop, watch)) { _dbus_warn ("Unable to add reload watch to main loop: %s\n", error.message); dbus_error_free (&error); exit (1); } }
static int _init_kqueue (BusContext *context) { if (kq < 0) { kq = kqueue (); if (kq < 0) { _dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno)); goto out; } loop = bus_context_get_loop (context); _dbus_loop_ref (loop); watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, _handle_kqueue_watch, NULL, NULL); if (watch == NULL) { _dbus_warn ("Unable to create kqueue watch\n"); goto out1; } if (!_dbus_loop_add_watch (loop, watch)) { _dbus_warn ("Unable to add reload watch to main loop"); goto out2; } if (!_dbus_register_shutdown_func (_shutdown_kqueue, NULL)) { _dbus_warn ("Unable to register shutdown function"); goto out3; } } return 1; out3: _dbus_loop_remove_watch (loop, watch); out2: if (watch) { _dbus_watch_invalidate (watch); _dbus_watch_unref (watch); watch = NULL; } out1: if (kq >= 0) { close (kq); kq = -1; } if (loop) { _dbus_loop_unref (loop); loop = NULL; } out: return 0; }
static dbus_bool_t add_client_watch (DBusWatch *watch, void *data) { return _dbus_loop_add_watch (client_loop, watch); }