/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "net.h"
#include "istream.h"
#include "write-full.h"
#include "strescape.h"
#include "time-util.h"
#include "settings-parser.h"
#include "mail-user.h"
#include "mail-storage-private.h"
#include "fts-api.h"
#include "fts-indexer.h"
struct fts_indexer_context {
unsigned int percentage;
unsigned int timeout_secs;
char *path;
int fd;
};
const char **path_r)
{
const char *path;
int fd;
if (fd == -1) {
return -1;
}
i_close_fd(&fd);
return -1;
}
return fd;
}
{
unsigned int eta_secs;
return;
ctx->percentage == 0)
return;
&ctx->search_start_time);
T_BEGIN {
const char *text;
} T_END;
}
struct fts_indexer_context **ctx_r)
{
int fd;
return -1;
/* everything is already indexed */
return 0;
}
if (seq1 == 0) {
/* no new messages (last messages in mailbox were expunged) */
return 0;
}
if (fd == -1)
return -1;
/* connect to indexer and request immediate indexing of the mailbox */
}
return 1;
}
{
/* we notified at least once */
}
return ret;
}
{
const char *line;
int percentage;
/* initial reply: <tag> \t OK
following: <tag> \t <percentage> */
return -1;
}
line += 2;
continue;
return -1;
}
if (percentage < 0) {
/* indexing failed */
i_error("indexer failed to index mailbox %s",
return -1;
}
if (percentage == 100) {
/* finished */
return 1;
}
}
i_error("indexer read(%s) failed: %s",
return -1;
}
i_error("indexer disconnected unexpectedly");
return -1;
}
return 0;
}
{
int ret;
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();
timeout_remove(&to);
return fts_indexer_input(ctx);
}
{
return -1;
}
if (ctx->timeout_secs > 0) {
"Timeout while waiting for indexing to finish");
return -1;
}
}
if (ret == 0)
return ret;
}