int avahi_simple_poll_dispatch(AvahiSimplePoll *s) { AvahiTimeout *next_timeout; AvahiWatch *w; assert(s); assert(s->state == STATE_RAN); s->state = STATE_DISPATCHING; /* We execute only on callback in every iteration */ /* Check whether the wakeup time has been reached now */ if ((next_timeout = find_next_timeout(s))) { if (next_timeout->expiry.tv_sec == 0 && next_timeout->expiry.tv_usec == 0) { /* Just a shortcut so that we don't need to call gettimeofday() */ timeout_callback(next_timeout); goto finish; } if (avahi_age(&next_timeout->expiry) >= 0) { /* Timeout elapsed */ timeout_callback(next_timeout); goto finish; } } /* Look for some kind of I/O event */ for (w = s->watches; w; w = w->watches_next) { if (w->dead) continue; assert(w->idx >= 0); assert(w->idx < s->n_pollfds); if (s->pollfds[w->idx].revents != 0) { w->callback(w, w->pollfd.fd, s->pollfds[w->idx].revents, w->userdata); goto finish; } } finish: s->state = STATE_DISPATCHED; return 0; }
static void on_connect_err(void *arg) { module_data_t *mod = arg; mod->is_connected = 1; timeout_callback(mod); on_close(mod); }
pmgr_listener::pmgr_listener(boost::asio::io_service &io_service, const std::string &ph, const std::string &ps, const boost::uint64_t fs, const std::string &s) : phost(ph), pservice(ps), service(s), free_space(fs), nr_read_pages(0), total_read_size(0), publisher(io_service), timeout_timer(io_service) { timeout_callback(boost::system::error_code()); }
void pmgr_listener::update_event(const boost::int32_t name, monitored_params_t ¶ms) { switch (name) { case PROVIDER_WRITE: free_space = params.get<0>(); if (free_space == 0) timeout_callback(boost::system::error_code()); INFO("write_page initiated by " << params.get<3>() << ", page size is: {" << params.get<2>().size() << "} (WPS)"); INFO("free space has changed, now is: {" << params.get<0>() << "} (FSC)"); break; case PROVIDER_READ: nr_read_pages++; total_read_size += params.get<2>().size(); INFO("read_page initiated by " << params.get<3>() << ", page size is: {" << params.get<2>().size() << "} (RPS)"); break; default: ERROR("Unknown hook type: " << name); } }
void pingring_ping(pingring_t **pring) { pingring_t *itr = *pring; time_t elapsed; if (itr == NULL) return; for (; itr != NULL; itr = itr->next) { if (itr->entry->lastseen == 0) { itr->entry->lastseen = time(NULL); continue; } elapsed = difftime(time(NULL), itr->entry->lastseen); if (elapsed > itr->entry->timeout && timeout_callback) timeout_callback(itr->entry); itr->pinger->ping(itr->pinger); } }
static void sigusr1_handler(int sig __attribute__((unused))) { // fprintf(stderr, "timeout: received SIGUSR1\n"); if (timeout_callback) timeout_callback(); }