struct master_auth *auth;
unsigned int tag;
+ char *path;
int fd;
struct io *io;
struct timeout *to;
struct master_service *service;
pool_t pool;
- const char *path;
+ const char *default_path;
unsigned int tag_counter;
HASH_TABLE(void *, struct master_auth_connection *) connections;
auth = p_new(pool, struct master_auth, 1);
auth->pool = pool;
auth->service = service;
- auth->path = p_strdup(pool, path);
+ auth->default_path = p_strdup(pool, path);
hash_table_create_direct(&auth->connections, pool, 0);
return auth;
}
io_remove(&conn->io);
if (conn->fd != -1) {
if (close(conn->fd) < 0)
- i_fatal("close(%s) failed: %m", conn->auth->path);
+ i_fatal("close(%s) failed: %m", conn->path);
conn->fd = -1;
}
+ i_free(conn->path);
i_free(conn);
}
if (ret == 0 || errno == ECONNRESET) {
i_error("read(%s) failed: Remote closed connection "
"(destination service { process_limit } reached?)",
- conn->auth->path);
+ conn->path);
} else {
if (errno == EAGAIN)
return;
- i_error("read(%s) failed: %m", conn->auth->path);
+ i_error("read(%s) failed: %m", conn->path);
}
master_auth_connection_deinit(&conn);
return;
if (conn->tag != reply->tag)
i_error("master(%s): Received reply with unknown tag %u",
- conn->auth->path, reply->tag);
+ conn->path, reply->tag);
else if (conn->callback == NULL) {
/* request aborted */
} else {
static void master_auth_connection_timeout(struct master_auth_connection *conn)
{
i_error("master(%s): Auth request timed out (received %u/%u bytes)",
- conn->auth->path, conn->buf_pos,
+ conn->path, conn->buf_pos,
(unsigned int)sizeof(conn->buf));
master_auth_connection_deinit(&conn);
}
conn->auth = auth;
conn->callback = callback;
conn->context = context;
+ conn->path = params->socket_path != NULL ?
+ i_strdup(params->socket_path) : i_strdup(auth->default_path);
req = params->request;
req.tag = ++auth->tag_counter;
buffer_append(buf, &req, sizeof(req));
buffer_append(buf, params->data, req.data_size);
- conn->fd = net_connect_unix_with_retries(auth->path,
+ conn->fd = net_connect_unix_with_retries(conn->path,
SOCKET_CONNECT_RETRY_MSECS);
if (conn->fd == -1) {
i_error("net_connect_unix(%s) failed: %m%s",
- auth->path, errno != EAGAIN ? "" :
+ conn->path, errno != EAGAIN ? "" :
" - http://wiki2.dovecot.org/SocketUnavailable");
master_auth_connection_deinit(&conn);
return;
ret = fd_send(conn->fd, params->client_fd, buf->data, buf->used);
if (ret < 0) {
- i_error("fd_send(%s, %d) failed: %m", auth->path,
+ i_error("fd_send(%s, %d) failed: %m", conn->path,
params->client_fd);
} else if ((size_t)ret != buf->used) {
i_error("fd_send(%s) sent only %d of %d bytes",
- auth->path, (int)ret, (int)buf->used);
+ conn->path, (int)ret, (int)buf->used);
ret = -1;
}
if (ret < 0) {