struct auth_worker_connection {
int fd;
+ struct event *event;
struct io *io;
struct istream *input;
struct ostream *output;
i_assert(conn->to != NULL);
if (age_secs >= AUTH_WORKER_ABORT_SECS) {
- i_error("Aborting auth request that was queued for %d secs, "
+ e_error(conn->event,
+ "Aborting auth request that was queued for %d secs, "
"%d left in queue",
age_secs, aqueue_count(worker_request_queue));
request->callback(t_strdup_printf(
ioloop_time - auth_worker_last_warn >
AUTH_WORKER_DELAY_WARN_MIN_INTERVAL_SECS) {
auth_worker_last_warn = ioloop_time;
- i_warning("auth workers: Auth request was queued for %d "
- "seconds, %d left in queue "
- "(see auth_worker_max_count)",
- age_secs, aqueue_count(worker_request_queue));
+ e_error(conn->event, "Auth request was queued for %d "
+ "seconds, %d left in queue "
+ "(see auth_worker_max_count)",
+ age_secs, aqueue_count(worker_request_queue));
}
request->id = ++conn->id_counter;
static struct auth_worker_connection *auth_worker_create(void)
{
struct auth_worker_connection *conn;
+ struct event *event;
int fd;
if (array_count(&connections) >= auth_workers_throttle_count)
return NULL;
+ event = event_create(auth_event);
+ event_set_append_log_prefix(event, "auth-worker: ");
+
fd = net_connect_unix_with_retries(worker_socket_path, 5000);
if (fd == -1) {
if (errno == EACCES) {
- i_error("%s", eacces_error_get("net_connect_unix",
- worker_socket_path));
+ e_error(event, "%s",
+ eacces_error_get("net_connect_unix",
+ worker_socket_path));
} else {
- i_error("net_connect_unix(%s) failed: %m",
+ e_error(event, "net_connect_unix(%s) failed: %m",
worker_socket_path);
}
+ event_unref(&event);
return NULL;
}
conn->io = io_add(fd, IO_READ, worker_input, conn);
conn->to = timeout_add(AUTH_WORKER_MAX_IDLE_SECS * 1000,
auth_worker_idle_timeout, conn);
+ conn->event = event;
auth_worker_send_handshake(conn);
idle_count++;
idle_count--;
if (conn->request != NULL) {
- i_error("auth worker: Aborted %s request for %s: %s",
+ e_error(conn->event, "Aborted %s request for %s: %s",
t_strcut(conn->request->data, '\t'),
conn->request->username, reason);
conn->request->callback(t_strdup_printf(
timeout_remove(&conn->to);
if (close(conn->fd) < 0)
- i_error("close(auth worker) failed: %m");
+ e_error(conn->event, "close() failed: %m");
+ event_unref(&conn->event);
i_free(conn);
if (idle_count == 0 && restart) {
return;
case -2:
/* buffer full */
- i_error("BUG: Auth worker sent us more than %d bytes",
+ e_error(conn->event,
+ "BUG: Auth worker sent us more than %d bytes",
(int)AUTH_WORKER_MAX_LINE_LENGTH);
auth_worker_destroy(&conn, "Worker is buggy", TRUE);
return;
break;
} else {
if (conn->request != NULL) {
- i_error("BUG: Worker sent reply with id %u, "
+ e_error(conn->event,
+ "BUG: Worker sent reply with id %u, "
"expected %u", id, conn->request->id);
} else {
- i_error("BUG: Worker sent reply with id %u, "
+ e_error(conn->event,
+ "BUG: Worker sent reply with id %u, "
"none was expected", id);
}
auth_worker_destroy(&conn, "Worker is buggy", TRUE);