/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "net.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "strescape.h"
#include "dsync-client.h"
#include <unistd.h>
struct dsync_client {
char *path;
int fd;
char *dsync_params;
char *username;
char *state;
void *context;
};
struct dsync_client *
{
return client;
}
{
/* make sure callback doesn't try to reuse this connection, since
we can't currently handle it */
}
{
return;
i_error("close(dsync) failed: %m");
}
{
}
{
}
{
const char *state;
if (!client->handshaked) {
i_error("%s: Unexpected handshake: %s",
return -1;
}
return 0;
}
return -1;
}
return 0;
}
if (line[0] == '+')
else if (line[0] == '-') {
else
} else {
return -1;
}
/* FIXME: disconnect after each request for now.
doveadm server's getopt() handling seems to break otherwise.
also with multiple UIDs doveadm-server fails because setid() fails */
return -1;
}
{
const char *line;
return;
}
}
}
{
return 0;
return -1;
return -1;
}
client->last_connect_failure = 0;
return 0;
}
{
}
{
unsigned int pos;
char *p;
if (full)
else
if (dsync_connect(client) < 0) {
} else {
/* <flags> <username> <command> [<args>] */
/* insert the parameters. we can do it simply by converting
spaces into tabs, it's unlikely we'll ever need anything
more complex here. */
for (; *p != '\0'; p++) {
if (*p == ' ')
*p = '\t';
}
if (full)
}
}
{
}
{
}
{
}
{
if (conn->last_connect_failure == 0)
return "Not connected";
}
if (!dsync_client_is_busy(conn))
return "Idle";
if (!conn->handshaked)
return "Waiting for handshake";
return "Waiting for dsync to finish";
else
return "Waiting for dsync to finish (second line)";
}