int unregister_watcher(str* _f, str* _t, notcb_t _c, void* _data) { udomain_t* d; urecord_t* r; if (find_domain(&dom, &d) > 0) { LOG(L_ERR, "unregister_watcher(): Domain '%.*s' not found\n", dom.len, ZSW(dom.s)); return -1; } lock_udomain(d); if (get_urecord(d, _t, &r) > 0) { unlock_udomain(d); DBG("unregister_watcher(): Record not found\n"); return 0; } remove_watcher(r, _c, _data); release_urecord(r); unlock_udomain(d); return 0; }
void uv__fs_event_destroy(uv_fs_event_t* handle) { inotify_rm_watch(handle->loop->inotify_fd, handle->fd); remove_watcher(handle); handle->fd = -1; free(handle->filename); handle->filename = NULL; }
void uv__fs_event_close(uv_fs_event_t* handle) { uv__inotify_rm_watch(handle->loop->inotify_fd, handle->fd); remove_watcher(handle); handle->fd = -1; free(handle->filename); handle->filename = NULL; uv__handle_stop(handle); }
static void idle_func (struct ev_loop *loop, ev_idle *watcher, int revents) { IdleWatcherPrivate *idle_watcher_priv; WatcherPrivate *watcher_priv; MilterLibevEventLoop *milter_event_loop; guint id; idle_watcher_priv = watcher->data; watcher_priv = WATCHER_PRIVATE(idle_watcher_priv); milter_event_loop = watcher_priv->loop; MILTER_LIBEV_EVENT_LOOP_GET_PRIVATE(milter_event_loop)->n_called++; id = watcher_priv->id; if (!idle_watcher_priv->function(watcher_priv->user_data)) { remove_watcher(milter_event_loop, id); } }
static void child_func (struct ev_loop *loop, ev_child *watcher, int revents) { ChildWatcherPrivate *child_watcher_priv; WatcherPrivate *watcher_priv; MilterLibevEventLoop *milter_event_loop; guint id; child_watcher_priv = watcher->data; watcher_priv = WATCHER_PRIVATE(child_watcher_priv); milter_event_loop = watcher_priv->loop; MILTER_LIBEV_EVENT_LOOP_GET_PRIVATE(milter_event_loop)->n_called++; id = watcher_priv->id; child_watcher_priv->function((GPid)(watcher->rpid), watcher->rstatus, watcher_priv->user_data); remove_watcher(milter_event_loop, id); }
static void io_func (struct ev_loop *loop, ev_io *watcher, int revents) { IOWatcherPrivate *io_watcher_priv; WatcherPrivate *watcher_priv; MilterLibevEventLoop *milter_event_loop; guint id; io_watcher_priv = watcher->data; watcher_priv = WATCHER_PRIVATE(io_watcher_priv); milter_event_loop = watcher_priv->loop; MILTER_LIBEV_EVENT_LOOP_GET_PRIVATE(milter_event_loop)->n_called++; id = watcher_priv->id; if (!io_watcher_priv->function(io_watcher_priv->channel, evcond_to_g_io_condition(revents), watcher_priv->user_data)) { remove_watcher(milter_event_loop, id); } }
static void destroy_subscription(pa_notify_cb_param_t *cbd) { presentity_t *p = NULL; watcher_t *w = NULL; /* if (find_pdomain(cbd->domain, &domain) != 0) { ERR("can't find PA domain\n"); return; } */ lock_pdomain(cbd->domain); if (get_watcher(cbd, &w, &p) != 0) { unlock_pdomain(cbd->domain); return; } remove_watcher(p, w); free_watcher(w); unlock_pdomain(cbd->domain); }
static gboolean remove (MilterEventLoop *loop, guint id) { return remove_watcher(MILTER_LIBEV_EVENT_LOOP(loop), id); }
int emittable::remove_all_watcher(bool now) { return now ? remove_watch_entry(NULL) : remove_watcher(NULL); }
/* * Update existing presentity and watcher list */ static int update_presentity(struct sip_msg* _m, struct pdomain* _d, struct presentity* _p, struct watcher** _w) { time_t e; dlg_t* dialog; str watch_uri; str watch_dn; event_t *event = NULL; int et = 0; if (_m->event) { event = (event_t*)(_m->event->parsed); et = event->parsed; } else { LOG(L_ERR, "update_presentity defaulting to EVENT_PRESENCE\n"); et = EVENT_PRESENCE; } if (_m->expires) { e = ((exp_body_t*)_m->expires->parsed)->val; } else { e = default_expires; } if (get_watch_uri(_m, &watch_uri, &watch_dn) < 0) { LOG(L_ERR, "update_presentity(): Error while extracting watcher URI\n"); return -1; } if (find_watcher(_p, &watch_uri, et, _w) == 0) { LOG(L_ERR, "update_presentity() found watcher\n"); if (e == 0) { if (et != EVENT_PRESENCE_WINFO) { if (remove_watcher(_p, *_w) < 0) { LOG(L_ERR, "update_presentity(): Error while deleting winfo watcher\n"); return -2; } } else { if (remove_winfo_watcher(_p, *_w) < 0) { LOG(L_ERR, "update_presentity(): Error while deleting winfo watcher\n"); return -2; } } (*_w)->expires = 0; /* The watcher will be freed after NOTIFY is sent */ if (!_p->watchers && !_p->winfo_watchers) { remove_presentity(_d, _p); } } else { e += act_time; if (update_watcher(*_w, e) < 0) { LOG(L_ERR, "update_presentity(): Error while updating watcher\n"); return -3; } } } else { if (e) { e += act_time; if (tmb.new_dlg_uas(_m, 200, &dialog) < 0) { paerrno = PA_DIALOG_ERR; LOG(L_ERR, "update_presentity(): Error while creating dialog state\n"); return -4; } if (et != EVENT_PRESENCE_WINFO) { if (add_watcher(_p, &watch_uri, e, et, acc, dialog, &watch_dn, _w) < 0) { LOG(L_ERR, "update_presentity(): Error while creating presentity\n"); tmb.free_dlg(dialog); return -5; } } else { if (add_winfo_watcher(_p, &watch_uri, e, et, acc, dialog, &watch_dn, _w) < 0) { LOG(L_ERR, "update_presentity(): Error while creating winfo watcher\n"); tmb.free_dlg(dialog); return -5; } } } else { DBG("update_presentity(): expires = 0 but no watcher found\n"); *_w = 0; } } return 0; }