Commit 37043503 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Closes #2195 closes[t:2195] Retry fsync on EINTR

git-svn-id: file:///svn/toku/tokudb@15958 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6282f733
/* -*- mode: C; c-basic-offset: 4 -*- */
#include <toku_portability.h>
#include <toku_atomic.h>
#include <unistd.h>
......@@ -89,6 +90,7 @@ static uint64_t get_tnow(void) {
return tv.tv_sec * 1000000ULL + tv.tv_usec;
}
// t_fsync exists for testing purposes only
static int (*t_fsync)(int) = 0;
static uint64_t toku_fsync_count;
static uint64_t toku_fsync_time;
......@@ -99,14 +101,19 @@ toku_set_func_fsync(int (*fsync_function)(int)) {
return 0;
}
// keep trying if fsync fails because of EINTR
int
toku_file_fsync(int fd) {
int r;
int r = -1;
uint64_t tstart = get_tnow();
while (r != 0) {
if (t_fsync)
r = t_fsync(fd);
else
r = fsync(fd);
if (r)
assert(errno==EINTR);
}
toku_sync_fetch_and_add_uint64(&toku_fsync_count, 1);
toku_sync_fetch_and_add_uint64(&toku_fsync_time, get_tnow() - tstart);
return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment