-f and -s parameters are added automatically when needed.
#define DSYNC_FAIL_TIMEOUT_MSECS (1000*5)
#define DOVEADM_HANDSHAKE "VERSION\tdoveadm-server\t1\t0\n"
-/* normally there shouldn't be any need for locking, since replicator doesn't
- start dsync in parallel for the same user. we'll do locking just in case
- anyway */
-#define DSYNC_LOCK_TIMEOUT_SECS 30
-
struct dsync_client {
char *path;
int fd;
struct ostream *output;
struct timeout *to;
+ char *dsync_params;
char *state;
dsync_callback_t *callback;
void *context;
unsigned int cmd_sent:1;
};
-struct dsync_client *dsync_client_init(const char *path)
+struct dsync_client *
+dsync_client_init(const char *path, const char *dsync_params)
{
struct dsync_client *client;
client = i_new(struct dsync_client, 1);
client->path = i_strdup(path);
client->fd = -1;
+ client->dsync_params = i_strdup(dsync_params);
return client;
}
dsync_callback_t *callback, void *context)
{
string_t *cmd;
+ unsigned int pos;
+ char *p;
i_assert(callback != NULL);
i_assert(!dsync_client_is_busy(client));
cmd = t_str_new(256);
str_append_c(cmd, '\t');
str_append_tabescaped(cmd, username);
- str_printfa(cmd, "\tsync\t-d\t-N\t-l\t%u", DSYNC_LOCK_TIMEOUT_SECS);
+ str_append(cmd, "\tsync\t");
+ pos = str_len(cmd);
+ /* insert the parameters. we can do it simply by converting
+ spaces into tabs, it's unlikely we'll ever need anything
+ more complex here. */
+ str_append(cmd, client->dsync_params);
+ p = str_c_modifiable(cmd) + pos;
+ for (; *p != '\0'; p++) {
+ if (*p == ' ')
+ *p = '\t';
+ }
if (full)
str_append(cmd, "\t-f");
- str_append(cmd, "\t-U\t-s\t");
+ str_append(cmd, "\t-s\t");
if (state != NULL)
str_append(cmd, state);
str_append_c(cmd, '\n');
typedef void dsync_callback_t(enum dsync_reply reply,
const char *state, void *context);
-struct dsync_client *dsync_client_init(const char *path);
+struct dsync_client *
+dsync_client_init(const char *path, const char *dsync_params);
void dsync_client_deinit(struct dsync_client **conn);
void dsync_client_sync(struct dsync_client *conn,
brain->set->replication_max_conns)
return NULL;
- conn = dsync_client_init(brain->set->doveadm_socket_path);
+ conn = dsync_client_init(brain->set->doveadm_socket_path,
+ brain->set->replication_dsync_parameters);
array_append(&brain->dsync_clients, &conn, 1);
return conn;
}
static const struct setting_define replicator_setting_defines[] = {
DEF(SET_STR, auth_socket_path),
DEF(SET_STR, doveadm_socket_path),
+ DEF(SET_STR, replication_dsync_parameters),
DEF(SET_TIME, replication_full_sync_interval),
DEF(SET_UINT, replication_max_conns),
const struct replicator_settings replicator_default_settings = {
.auth_socket_path = "auth-userdb",
.doveadm_socket_path = "doveadm-server",
+ .replication_dsync_parameters = "-d -N -l 30 -U",
.replication_full_sync_interval = 60*60*24,
.replication_max_conns = 10
struct replicator_settings {
const char *auth_socket_path;
const char *doveadm_socket_path;
+ const char *replication_dsync_parameters;
unsigned int replication_full_sync_interval;
unsigned int replication_max_conns;