Commit 63bc7424 authored by Rich Prohaska's avatar Rich Prohaska

#17 gracefull db open

parent a881aeae
......@@ -3534,10 +3534,13 @@ static int ft_create_file(FT_HANDLE UU(brt), const char *fname, int *fdp) {
}
r = toku_fsync_directory(fname);
resource_assert_zero(r);
if (r == 0) {
*fdp = fd;
return 0;
} else {
int rr = close(fd);
assert_zero(rr);
}
return r;
}
// open a file for use by the brt. if the file does not exist, error
......@@ -3687,7 +3690,7 @@ ft_handle_open(FT_HANDLE ft_h, const char *fname_in_env, int is_create, int only
txn_created = (bool)(txn!=NULL);
toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, ft_h->options.flags, ft_h->options.nodesize, ft_h->options.basementnodesize, ft_h->options.compression_method);
r = ft_create_file(ft_h, fname_in_cwd, &fd);
assert_zero(r);
if (r) { goto exit; }
}
if (r) { goto exit; }
r=toku_cachetable_openfd_with_filenum(&cf, cachetable, fd, fname_in_env, reserved_filenum);
......
......@@ -194,7 +194,6 @@ toku_rollback_fcreate (FILENUM filenum,
// is not an error, but a missing file outside of recovery is.
r = toku_cachefile_of_filenum(ct, filenum, &cf);
if (r == ENOENT) {
assert(txn->for_recovery);
r = 0;
goto done;
}
......
......@@ -133,6 +133,10 @@ PATENT RIGHTS GRANT:
int
toku_portability_init(void) {
int r = toku_memory_startup();
if (r == 0) {
uint64_t hz;
r = toku_os_get_processor_frequency(&hz);
}
return r;
}
......@@ -368,8 +372,7 @@ toku_get_processor_frequency_sysctl(const char * const cmd, uint64_t *hzret) {
if (!fp) {
r = EINVAL; // popen doesn't return anything useful in errno,
// gotta pick something
goto exit;
}
} else {
r = fscanf(fp, "%" SCNu64, hzret);
if (r != 1) {
r = get_maybe_error_errno();
......@@ -377,14 +380,19 @@ toku_get_processor_frequency_sysctl(const char * const cmd, uint64_t *hzret) {
r = 0;
}
pclose(fp);
exit:
}
return r;
}
static uint64_t toku_cached_hz; // cache the value of hz so that we avoid opening files to compute it later
int
toku_os_get_processor_frequency(uint64_t *hzret) {
int r;
if (toku_cached_hz) {
*hzret = toku_cached_hz;
r = 0;
} else {
r = toku_get_processor_frequency_sys(hzret);
if (r != 0)
r = toku_get_processor_frequency_cpuinfo(hzret);
......@@ -392,6 +400,9 @@ toku_os_get_processor_frequency(uint64_t *hzret) {
r = toku_get_processor_frequency_sysctl("sysctl -n hw.cpufrequency", hzret);
if (r != 0)
r = toku_get_processor_frequency_sysctl("sysctl -n machdep.tsc_freq", hzret);
if (r == 0)
toku_cached_hz = *hzret;
}
return r;
}
......@@ -439,3 +450,10 @@ double tokutime_to_seconds(tokutime_t t) {
}
return t*seconds_per_clock;
}
#include <toku_race_tools.h>
void __attribute__((constructor)) toku_portability_helgrind_ignore(void);
void
toku_portability_helgrind_ignore(void) {
TOKU_VALGRIND_HG_DISABLE_CHECKING(&toku_cached_hz, sizeof toku_cached_hz);
}
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