static void replication_notify(struct mail_namespace *ns, enum replication_priority priority, const char *event) { struct replication_user *ruser; ruser = REPLICATION_USER_CONTEXT(ns->user); if (ruser == NULL) return; if (ns->user->mail_debug) { i_debug("replication: Replication requested by '%s', priority=%d", event, priority); } if (priority == REPLICATION_PRIORITY_SYNC) { if (replication_notify_sync(ns->user) == 0) { timeout_remove(&ruser->to); ruser->priority = REPLICATION_PRIORITY_NONE; return; } /* sync replication failed, try as "high" via fifo */ priority = REPLICATION_PRIORITY_HIGH; } if (ruser->priority < priority) ruser->priority = priority; if (ruser->to == NULL) { ruser->to = timeout_add_short(REPLICATION_NOTIFY_DELAY_MSECS, replication_notify_now, ns->user); } }
void http_client_delay_request_error(struct http_client *client, struct http_client_request *req) { if (client->to_failing_requests == NULL) { client->to_failing_requests = timeout_add_short(0, http_client_handle_request_errors, client); } array_append(&client->delayed_failing_requests, &req, 1); }
static void notify_callback(struct mailbox *box) { struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box); timeout_reset(ibox->notify_to); if (ibox->notify_delay_to == NULL) { ibox->notify_delay_to = timeout_add_short(NOTIFY_DELAY_MSECS, notify_delay_callback, box); } }
static void imapc_mailbox_idle_notify(struct imapc_mailbox *mbox) { struct ioloop *old_ioloop = current_ioloop; if (mbox->box.notify_callback != NULL && mbox->to_idle_delay == NULL) { io_loop_set_current(mbox->storage->root_ioloop); mbox->to_idle_delay = timeout_add_short(NOTIFY_DELAY_MSECS, imapc_mailbox_idle_timeout, mbox); io_loop_set_current(old_ioloop); } }
static void auth_request_handle_failure(struct auth_request *request, const char *reply) { struct auth_request_handler *handler = request->handler; if (request->in_delayed_failure_queue) { /* we came here from flush_failures() */ handler->callback(reply, handler->context); return; } /* remove the request from requests-list */ auth_request_ref(request); auth_request_handler_remove(handler, request); if (auth_fields_exists(request->extra_fields, "nodelay")) { /* passdb specifically requested not to delay the reply. */ handler->callback(reply, handler->context); auth_request_unref(&request); return; } /* failure. don't announce it immediately to avoid a) timing attacks, b) flooding */ request->in_delayed_failure_queue = TRUE; handler->refcount++; if (auth_penalty != NULL) { auth_penalty_update(auth_penalty, request, request->last_penalty + 1); } auth_request_refresh_last_access(request); aqueue_append(auth_failures, &request); if (to_auth_failures == NULL) { to_auth_failures = timeout_add_short(AUTH_FAILURE_DELAY_CHECK_MSECS, auth_failure_timeout, (void *)NULL); } }
static int fts_indexer_more_int(struct fts_indexer_context *ctx) { struct ioloop *ioloop; struct io *io; struct timeout *to; int ret; if ((ret = fts_indexer_input(ctx)) != 0) return ret; /* wait for a while for the reply. FIXME: once search API supports asynchronous waits, get rid of this wait and use the mail IO loop */ ioloop = io_loop_create(); io = io_add(ctx->fd, IO_READ, io_loop_stop, ioloop); to = timeout_add_short(INDEXER_WAIT_MSECS, io_loop_stop, ioloop); io_loop_run(ioloop); io_remove(&io); timeout_remove(&to); io_loop_destroy(&ioloop); return fts_indexer_input(ctx); }
static void worker_status_callback(int percentage, void *context) { struct worker_request *request = context; if (percentage >= 0 && percentage < 100) { indexer_queue_request_status(queue, request->request, percentage); return; } indexer_queue_request_finish(queue, &request->request, percentage == 100); if (worker_pool != NULL) /* not in deinit */ worker_pool_release_connection(worker_pool, request->conn); i_free(request); /* if this was the last request for the connection, we can send more through it. delay it a bit, since we may be coming here from worker_connection_disconnect() and we want to finish it up. */ if (to_send_more == NULL) to_send_more = timeout_add_short(0, queue_try_send_more, queue); }