/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "write-full.h"
#include "strescape.h"
#include "process-title.h"
#include "master-service.h"
#include "master-service-settings.h"
#include "mail-namespace.h"
#include "mail-storage-private.h"
#include "mail-storage-service.h"
#include "mail-search-build.h"
#include "master-connection.h"
#include <unistd.h>
#define INDEXER_PROTOCOL_MINOR_VERSION 0
struct master_connection {
int fd;
};
{
return;
process_title_set("[idling]");
else if (seq1 == 0)
else {
}
}
static int
{
int ret = 0;
&metadata) < 0) {
i_error("Mailbox %s: Precache-fields lookup failed: %s",
return -1;
}
&status) < 0) {
i_error("Mailbox %s: Status lookup failed: %s",
return -1;
}
"indexing");
if (first_uid == 0)
if (++counter % 100 == 0) {
if (i_snprintf(percentage_str,
sizeof(percentage_str), "%u\n",
percentage) < 0)
i_unreached();
}
}
}
if (mailbox_search_deinit(&ctx) < 0) {
i_error("Mailbox %s: Mail search failed: %s",
ret = -1;
}
if (mailbox_transaction_commit(&trans) < 0) {
i_error("Mailbox %s: Transaction commit failed: %s"
" (attempted to index %u messages%s)",
ret = -1;
} else {
i_info("Indexed %u messages in %s%s",
}
return ret;
}
static int
const char *mailbox, unsigned int max_recent_msgs,
const char *what)
{
int ret;
if (ret < 0) {
i_error("Getting path to mailbox %s failed: %s",
mailbox_free(&box);
return -1;
}
if (ret == 0) {
mailbox_free(&box);
return 0;
}
ret = 0;
if (max_recent_msgs != 0) {
/* index only if there aren't too many recent messages.
don't bother syncing the mailbox, that alone can take a
while with large maildirs. */
if (mailbox_open(box) < 0) {
ret = -1;
} else {
}
mailbox_free(&box);
return ret;
}
}
if (error != MAIL_ERROR_NOTFOUND) {
i_error("Syncing mailbox %s failed: %s",
} else if (user->mail_debug) {
i_debug("Syncing mailbox %s failed: %s",
}
ret = -1;
ret = -1;
}
mailbox_free(&box);
return ret;
}
static int
{
unsigned int max_recent_msgs;
int ret;
/* <username> <mailbox> <session ID> <max_recent_msgs> [i][o] */
return -1;
}
/* if session-id is given, use it as a prefix to a unique session ID.
we can't use the session-id directly or stats process will complain
about duplicates. (especially LMTP would use the same session-id for
multiple users' indexing at the same time.) */
ret = -1;
} else {
/* refresh proctitle before a potentially long-running
user unref */
}
}
{
const char *line;
int ret;
return;
}
if (!conn->version_received) {
return;
i_error("Indexer master not compatible with this master "
"(mixed old and new binaries?)");
return;
}
}
T_BEGIN {
} T_END;
if (ret < 0) {
break;
}
}
}
struct master_connection *
{
const char *handshake;
return conn;
}
{
i_error("close(master conn) failed: %m");
}