#include "str.h"
#include "strescape.h"
#include "var-expand.h"
+#include "process-title.h"
#include "settings-parser.h"
#include "imap-util.h"
#include "master-service.h"
ioloop = io_loop_create();
+ if (doveadm_verbose_proctitle) {
+ process_title_set(t_strdup_printf(
+ "[dsync - connecting to %s]", server->name));
+ }
if (server_connection_create(server, &conn) < 0) {
*error_r = "Couldn't create server connection";
return -1;
str_append(cmd, "\t-U");
str_append_c(cmd, '\n');
+ if (doveadm_verbose_proctitle) {
+ process_title_set(t_strdup_printf(
+ "[dsync - running dsync-server on %s]", server->name));
+ }
+
ctx->tcp_conn = conn;
server_connection_cmd(conn, str_c(cmd), NULL,
dsync_connected_callback, ctx);
#include <sys/stat.h>
+enum dsync_brain_title {
+ DSYNC_BRAIN_TITLE_NONE = 0,
+ DSYNC_BRAIN_TITLE_LOCKING,
+};
+
static const char *dsync_state_names[] = {
"master_recv_handshake",
"slave_recv_handshake",
static void dsync_brain_mailbox_states_dump(struct dsync_brain *brain);
-static const char *dsync_brain_get_proctitle(struct dsync_brain *brain)
+static const char *
+dsync_brain_get_proctitle_full(struct dsync_brain *brain,
+ enum dsync_brain_title title)
{
string_t *str = t_str_new(128);
const char *import_title, *export_title;
}
}
}
+ switch (title) {
+ case DSYNC_BRAIN_TITLE_NONE:
+ break;
+ case DSYNC_BRAIN_TITLE_LOCKING:
+ str_append(str, " locking "DSYNC_LOCK_FILENAME);
+ break;
+ }
str_append_c(str, ']');
return str_c(str);
}
+static const char *dsync_brain_get_proctitle(struct dsync_brain *brain)
+{
+ return dsync_brain_get_proctitle_full(brain, DSYNC_BRAIN_TITLE_NONE);
+}
+
static void dsync_brain_run_io(void *context)
{
struct dsync_brain *brain = context;
dsync_ibc_set_io_callback(ibc, dsync_brain_run_io, brain);
brain->state = DSYNC_STATE_MASTER_RECV_HANDSHAKE;
+
+ if (brain->verbose_proctitle)
+ process_title_set(dsync_brain_get_proctitle(brain));
return brain;
}
ibc_set.hostname = my_hostdomain();
dsync_ibc_send_handshake(ibc, &ibc_set);
+ if (brain->verbose_proctitle)
+ process_title_set(dsync_brain_get_proctitle(brain));
dsync_ibc_set_io_callback(ibc, dsync_brain_run_io, brain);
return brain;
}
return -1;
}
+ if (brain->verbose_proctitle)
+ process_title_set(dsync_brain_get_proctitle_full(brain, DSYNC_BRAIN_TITLE_LOCKING));
brain->lock_path = p_strconcat(brain->pool, home,
"/"DSYNC_LOCK_FILENAME, NULL);
for (;;) {
if (brain->lock_fd == -1) {
i_error("Couldn't create lock %s: %m",
brain->lock_path);
- return -1;
+ break;
}
if (file_wait_lock(brain->lock_fd, brain->lock_path, F_WRLCK,
}
} else if (st1.st_ino == st2.st_ino) {
/* success */
+ if (brain->verbose_proctitle)
+ process_title_set(dsync_brain_get_proctitle(brain));
return 0;
}
/* file was recreated, try again */
i_close_fd(&brain->lock_fd);
}
- i_close_fd(&brain->lock_fd);
+ if (brain->lock_fd != -1)
+ i_close_fd(&brain->lock_fd);
+ if (brain->verbose_proctitle)
+ process_title_set(dsync_brain_get_proctitle(brain));
return -1;
}