diff --git a/src/box/journal.c b/src/box/journal.c index 83d2e7145bbf0a4d79894d459fe94757387f4b03..40fe426ae35673e9e92a27674bbdc74febee5efa 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -33,6 +33,7 @@ #include <diag.h> #include "error.h" #include "watcher.h" +#include "xrow.h" struct journal *current_journal = NULL; @@ -123,3 +124,21 @@ journal_queue_flush(void) fiber_wakeup(rlist_first_entry(list, struct fiber, state)); journal_queue_wait(); } + +int +journal_write_row(struct xrow_header *row) +{ + char buf[sizeof(struct journal_entry) + sizeof(struct xrow_header *)]; + struct journal_entry *entry = (struct journal_entry *)buf; + entry->rows[0] = row; + journal_entry_create(entry, 1, xrow_approx_len(row), + journal_entry_fiber_wakeup_cb, fiber()); + + if (journal_write(entry) != 0) + return -1; + if (entry->res < 0) { + diag_set_journal_res(entry->res); + return -1; + } + return 0; +} diff --git a/src/box/journal.h b/src/box/journal.h index 7d3e525f8f451b0d5e6412b4b3baea88d012d86c..0147083eca6d405bad0cc5e6269765551ff65c4c 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -277,6 +277,10 @@ journal_write(struct journal_entry *entry) return current_journal->write(current_journal, entry); } +/** Write a single row in a blocking way. */ +int +journal_write_row(struct xrow_header *row); + /** * Queue a single entry to the journal in asynchronous way. * diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index dd5aeec1bc371b19063c9977db045066d4db5209..6ea624c2736ec291aaa0898ee60e902aca5e5145 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -382,25 +382,9 @@ synchro_request_write(const struct synchro_request *req) */ char body[XROW_BODY_LEN_MAX]; struct xrow_header row; - char buf[sizeof(struct journal_entry) + - sizeof(struct xrow_header *)]; - - struct journal_entry *entry = (struct journal_entry *)buf; - entry->rows[0] = &row; - xrow_encode_synchro(&row, body, req); - - journal_entry_create(entry, 1, xrow_approx_len(&row), - journal_entry_fiber_wakeup_cb, fiber()); - - if (journal_write(entry) != 0) - goto fail; - if (entry->res < 0) { - diag_set_journal_res(entry->res); - goto fail; - } - return; -fail: + if (journal_write_row(&row) == 0) + return; diag_log(); /* * XXX: the stub is supposed to be removed once it is defined what to do