From: Aki Tuomi Date: Thu, 8 Jul 2021 08:10:38 +0000 (+0300) Subject: plugins/fts: Restore fts_indexer_cmd X-Git-Tag: 2.3.16~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd4ec646cc0b81f18ac28f7b6357d122be8b557b;p=thirdparty%2Fdovecot%2Fcore.git plugins/fts: Restore fts_indexer_cmd It was removed in cf114f90e0ba25c18db846ee582e3a130bd52949 and that broke some FTS plugins. --- diff --git a/src/plugins/fts/fts-indexer.c b/src/plugins/fts/fts-indexer.c index 4fbefb0e6b..c203771d5d 100644 --- a/src/plugins/fts/fts-indexer.c +++ b/src/plugins/fts/fts-indexer.c @@ -3,6 +3,7 @@ #include "lib.h" #include "ioloop.h" #include "connection.h" +#include "write-full.h" #include "istream.h" #include "ostream.h" #include "strescape.h" @@ -267,3 +268,29 @@ int fts_indexer_init(struct fts_backend *backend, struct mailbox *box, *ctx_r = ctx; return ctx->failed || ret < 0 ? -1 : 1; } + +#define INDEXER_HANDSHAKE "1\t0\tindexer\tindexer\n" + +int fts_indexer_cmd(struct mail_user *user, const char *cmd, + const char **path_r) +{ + const char *path; + int fd; + + path = t_strconcat(user->set->base_dir, + "/"INDEXER_SOCKET_NAME, NULL); + fd = net_connect_unix_with_retries(path, 1000); + if (fd == -1) { + i_error("net_connect_unix(%s) failed: %m", path); + return -1; + } + + cmd = t_strconcat(INDEXER_HANDSHAKE, cmd, NULL); + if (write_full(fd, cmd, strlen(cmd)) < 0) { + i_error("write(%s) failed: %m", path); + i_close_fd(&fd); + return -1; + } + *path_r = path; + return fd; +}