const char *const *args, const char **error_r)
{
struct indexer_client_request *ctx = NULL;
+ const char *session_id = NULL;
unsigned int tag, max_recent_msgs;
- /* <tag> <user> <mailbox> [<max_recent_msgs>] */
+ /* <tag> <user> <mailbox> [<max_recent_msgs> [<session ID>]] */
if (str_array_length(args) < 3) {
*error_r = "Wrong parameter count";
return -1;
else if (str_to_uint(args[3], &max_recent_msgs) < 0) {
*error_r = "Invalid max_recent_msgs";
return -1;
+ } else {
+ session_id = args[4];
}
if (tag != 0) {
}
indexer_queue_append(client->queue, append, args[1], args[2],
- max_recent_msgs, ctx);
+ session_id, max_recent_msgs, ctx);
o_stream_nsend_str(client->output, t_strdup_printf("%u\tOK\n", tag));
return 0;
}
static struct indexer_request *
indexer_queue_append_request(struct indexer_queue *queue, bool append,
const char *username, const char *mailbox,
+ const char *session_id,
unsigned int max_recent_msgs, void *context)
{
struct indexer_request *request;
request = i_new(struct indexer_request, 1);
request->username = i_strdup(username);
request->mailbox = i_strdup(mailbox);
+ request->session_id = i_strdup(session_id);
request->max_recent_msgs = max_recent_msgs;
request_add_context(request, context);
hash_table_insert(queue->requests, request, request);
void indexer_queue_append(struct indexer_queue *queue, bool append,
const char *username, const char *mailbox,
- unsigned int max_recent_msgs, void *context)
+ const char *session_id, unsigned int max_recent_msgs,
+ void *context)
{
struct indexer_request *request;
request = indexer_queue_append_request(queue, append, username, mailbox,
- max_recent_msgs, context);
+ session_id, max_recent_msgs,
+ context);
request->index = TRUE;
indexer_queue_append_finish(queue);
}
struct indexer_request *request;
request = indexer_queue_append_request(queue, TRUE, username, mailbox,
- 0, context);
+ NULL, 0, context);
request->optimize = TRUE;
indexer_queue_append_finish(queue);
}
char *username;
char *mailbox;
+ char *session_id;
unsigned int max_recent_msgs;
/* index messages in this mailbox */
void indexer_queue_append(struct indexer_queue *queue, bool append,
const char *username, const char *mailbox,
- unsigned int max_recent_msgs, void *context);
+ const char *session_id, unsigned int max_recent_msgs,
+ void *context);
void indexer_queue_append_optimize(struct indexer_queue *queue,
const char *username, const char *mailbox,
void *context);
unsigned int max_recent_msgs;
int ret;
- /* <username> <mailbox> <max_recent_msgs> [i][o] */
- if (str_array_length(args) != 4 ||
- str_to_uint(args[2], &max_recent_msgs) < 0 || args[3][0] == '\0') {
+ /* <username> <mailbox> <session ID> <max_recent_msgs> [i][o] */
+ if (str_array_length(args) != 5 ||
+ str_to_uint(args[3], &max_recent_msgs) < 0 || args[4][0] == '\0') {
i_error("Invalid input from master: %s", line);
return -1;
}
input.module = "mail";
input.service = "indexer-worker";
input.username = args[0];
+ input.session_id = args[2][0] == '\0' ? NULL : args[2];
if (mail_storage_service_lookup_next(conn->storage_service, &input,
&service_user, &user, &error) <= 0) {
} else {
indexer_worker_refresh_proctitle(user->username, args[1], 0, 0);
ret = index_mailbox(conn, user, args[1],
- max_recent_msgs, args[3]);
+ max_recent_msgs, args[4]);
indexer_worker_refresh_proctitle(NULL, NULL, 0, 0);
mail_user_unref(&user);
mail_storage_service_user_free(&service_user);
str_append_tabescaped(str, request->username);
str_append_c(str, '\t');
str_append_tabescaped(str, request->mailbox);
+ str_append_c(str, '\t');
+ if (request->session_id != NULL)
+ str_append_tabescaped(str, request->session_id);
str_printfa(str, "\t%u\t", request->max_recent_msgs);
if (request->index)
str_append_c(str, 'i');
return 0;
}
- cmd = t_strdup_printf("PREPEND\t1\t%s\t%s\n",
+ cmd = t_strdup_printf("PREPEND\t1\t%s\t%s\t0\t%s\n",
str_tabescape(box->storage->user->username),
- str_tabescape(box->vname));
+ str_tabescape(box->vname),
+ str_tabescape(box->storage->user->session_id));
fd = fts_indexer_cmd(box->storage->user, cmd, &path);
if (fd == -1)
return -1;
str_append_tabescaped(str, user->username);
str_append_c(str, '\t');
str_append_tabescaped(str, box->vname);
- str_printfa(str, "\t%u\n", max_recent_msgs);
+ str_printfa(str, "\t%u", max_recent_msgs);
+ str_append_c(str, '\t');
+ str_append_tabescaped(str, box->storage->user->session_id);
+ str_append_c(str, '\n');
if (write_full(fd, str_data(str), str_len(str)) < 0)
i_error("write(%s) failed: %m", path);
i_close_fd(&fd);