return 0;
}
+static int
+cmd_commit_async(struct dict_client_connection *conn, const char *line)
+{
+ struct dict_server_transaction *trans;
+
+ if (conn->iter_ctx != NULL) {
+ i_error("dict client: COMMIT: Can't commit while iterating");
+ return -1;
+ }
+
+ if (dict_server_transaction_lookup_parse(conn, line, &trans) < 0)
+ return -1;
+
+ dict_transaction_commit_async(&trans->ctx);
+ dict_server_transaction_array_remove(conn, trans);
+ return 0;
+}
+
static int cmd_rollback(struct dict_client_connection *conn, const char *line)
{
struct dict_server_transaction *trans;
{ DICT_PROTOCOL_CMD_ITERATE, cmd_iterate },
{ DICT_PROTOCOL_CMD_BEGIN, cmd_begin },
{ DICT_PROTOCOL_CMD_COMMIT, cmd_commit },
+ { DICT_PROTOCOL_CMD_COMMIT_ASYNC, cmd_commit_async },
{ DICT_PROTOCOL_CMD_ROLLBACK, cmd_rollback },
{ DICT_PROTOCOL_CMD_SET, cmd_set },
{ DICT_PROTOCOL_CMD_UNSET, cmd_unset },
struct istream *input;
struct ostream *output;
- unsigned int skip_lines;
unsigned int connect_counter;
unsigned int transaction_id_counter;
while ((ret = i_stream_read(dict->input)) > 0) {
line = i_stream_next_line(dict->input);
- if (line != NULL) {
- if (dict->skip_lines == 0)
- return line;
- /* ignore this reply and wait for the next line */
- dict->skip_lines--;
- }
+ if (line != NULL)
+ return line;
}
i_assert(ret < 0);
if (ctx->sent_begin) T_BEGIN {
const char *query, *line;
- query = t_strdup_printf("%c%u\n", !ctx->failed ?
- DICT_PROTOCOL_CMD_COMMIT :
- DICT_PROTOCOL_CMD_ROLLBACK, ctx->id);
+ query = t_strdup_printf("%c%u\n", ctx->failed ?
+ DICT_PROTOCOL_CMD_ROLLBACK :
+ (!async ? DICT_PROTOCOL_CMD_COMMIT :
+ DICT_PROTOCOL_CMD_COMMIT_ASYNC),
+ ctx->id);
if (client_dict_send_transaction_query(ctx, query) < 0)
ret = -1;
else if (ret < 0) {
/* rollback sent, it has no reply */
- } else if (async) {
- /* don't wait for the reply. if we read it later,
- ignore it. */
- dict->skip_lines++;
} else {
/* read reply */
line = client_dict_read_line(dict);
DICT_PROTOCOL_CMD_BEGIN = 'B', /* <id> */
DICT_PROTOCOL_CMD_COMMIT = 'C', /* <id> */
+ DICT_PROTOCOL_CMD_COMMIT_ASYNC = 'D', /* <id> */
DICT_PROTOCOL_CMD_ROLLBACK = 'R', /* <id> */
DICT_PROTOCOL_CMD_SET = 'S', /* <id> <key> <value> */