diff --git a/src/box/journal.c b/src/box/journal.c index 7de14908027e65b714f053b0f943ef6ca51bf6b2..da29658896a26fe8881c1e15cf87cededcbfff62 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -32,6 +32,7 @@ #include <small/region.h> #include <diag.h> #include "error.h" +#include "xrow.h" struct journal *current_journal = NULL; @@ -118,3 +119,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 00618bb94424dbef7b34077cc452634c0ba041a0..46157af1fc9bf3d149c710d3633ab1696ae84658 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -380,25 +380,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