From 730e17faafdd001824959f387952a70f75596691 Mon Sep 17 00:00:00 2001 From: Rich Prohaska Date: Tue, 16 Apr 2013 23:57:27 -0400 Subject: [PATCH] merge 1032 into 1032b. addresses #1032 git-svn-id: file:///svn/toku/tokudb.1032b@7781 c7de825b-a66e-492c-adef-691d508d4ae1 --- newbrt/brt.c | 4 +- newbrt/brtdump.c | 2 +- newbrt/cachetable.c | 2 +- newbrt/log.c | 6 +- newbrt/recover.c | 4 +- newbrt/roll.c | 4 +- newbrt/tests/bread-test.c | 9 +-- newbrt/tests/brt-serialize-test.c | 2 +- newbrt/tests/cachetable-checkpoint-test.c | 2 +- newbrt/tests/cachetable-count-pinned-test.c | 2 +- newbrt/tests/cachetable-debug-test.c | 2 +- newbrt/tests/cachetable-fd-test.c | 11 ++-- newbrt/tests/cachetable-flush-test.c | 4 +- newbrt/tests/cachetable-getandpin-test.c | 2 +- newbrt/tests/cachetable-put-test.c | 2 +- newbrt/tests/cachetable-rename-test.c | 3 +- newbrt/tests/cachetable-scan.c | 13 ++-- newbrt/tests/cachetable-test.c | 68 ++++++++++----------- newbrt/tests/cachetable-test2.c | 6 +- newbrt/tests/cachetable-unpin-test.c | 2 +- newbrt/tests/cachetable-writequeue-test.c | 2 +- newbrt/tests/log-test.c | 8 +-- newbrt/tests/log-test2.c | 2 +- newbrt/tests/log-test3.c | 2 +- newbrt/tests/log-test4.c | 2 +- newbrt/tests/log-test5.c | 2 +- newbrt/tests/log-test6.c | 2 +- newbrt/tests/test-del-inorder.c | 2 +- newbrt/tests/test-inc-split.c | 6 +- newbrt/tests/test-leafentry.c | 3 +- newbrt/tests/test_oexcl.c | 4 +- newbrt/tests/threadpool-test.c | 14 ++++- 32 files changed, 105 insertions(+), 94 deletions(-) diff --git a/newbrt/brt.c b/newbrt/brt.c index 4572c7e7fa5..d548ce01afb 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -2618,14 +2618,14 @@ static int brt_open_file(BRT brt, const char *fname, const char *fname_in_env, i brt = brt; mode_t mode = 0777; int r; - int fd = open(fname, O_RDWR, mode); + int fd = open(fname, O_RDWR | O_BINARY, mode); if (fd==-1) { r = errno; if (errno == ENOENT) { if (!is_create) { return r; } - fd = open(fname, O_RDWR | O_CREAT, mode); + fd = open(fname, O_RDWR | O_CREAT | O_BINARY, mode); if (fd == -1) { r = errno; return r; } diff --git a/newbrt/brtdump.c b/newbrt/brtdump.c index c06ceecffdb..2fc7cf1c1be 100644 --- a/newbrt/brtdump.c +++ b/newbrt/brtdump.c @@ -254,7 +254,7 @@ main (int argc, const char *argv[]) { } assert(argc==1); const char *n = argv[0]; - int f = open(n, O_RDONLY); assert(f>=0); + int f = open(n, O_RDONLY + O_BINARY); assert(f>=0); struct brt_header *h; dump_header(f, &h); if (interactive) { diff --git a/newbrt/cachetable.c b/newbrt/cachetable.c index 9e75a399809..c4ed24cac60 100644 --- a/newbrt/cachetable.c +++ b/newbrt/cachetable.c @@ -233,7 +233,7 @@ int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd, const char *fna } int toku_cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) { - int fd = open(fname, flags, mode); + int fd = open(fname, flags+O_BINARY, mode); if (fd<0) return errno; return toku_cachetable_openfd (cf, t, fd, fname); } diff --git a/newbrt/log.c b/newbrt/log.c index 90e67c3fb78..3abc40a9df5 100644 --- a/newbrt/log.c +++ b/newbrt/log.c @@ -141,7 +141,7 @@ static int open_logfile (TOKULOGGER logger) { if (logger->write_log_files) { logger->fd = creat(fname, O_EXCL | 0700); if (logger->fd==-1) return errno; } else { - logger->fd = open(dev_null, O_RDWR); if (logger->fd==-1) return errno; + logger->fd = open(dev_null, O_RDWR+O_BINARY); if (logger->fd==-1) return errno; } logger->next_log_file_number++; int version_l = htonl(log_format_version); @@ -864,7 +864,7 @@ int toku_set_func_fsync (int (*fsync_function)(int)) { // Find the earliest LSN in a log static int peek_at_log (TOKULOGGER logger, char* filename, LSN *first_lsn) { logger=logger; - int fd = open(filename, O_RDONLY); + int fd = open(filename, O_RDONLY+O_BINARY); if (fd<0) { if (logger->write_log_files) printf("couldn't open: %s\n", strerror(errno)); return errno; @@ -986,7 +986,7 @@ int toku_maybe_spill_rollbacks (TOKUTXN txn) { txn->rollentry_filename = toku_malloc(fnamelen); if (txn->rollentry_filename==0) return errno; snprintf(txn->rollentry_filename, fnamelen, "%s%s%.16"PRIx64, txn->logger->directory, filenamepart, txn->txnid64); - txn->rollentry_fd = open(txn->rollentry_filename, O_CREAT+O_RDWR+O_EXCL, 0600); + txn->rollentry_fd = open(txn->rollentry_filename, O_CREAT+O_RDWR+O_EXCL+O_BINARY, 0600); if (txn->rollentry_fd==-1) return errno; } ssize_t r = write_it(txn->rollentry_fd, buf, w.ndone); diff --git a/newbrt/recover.c b/newbrt/recover.c index 336ae6e9343..927fea026bc 100644 --- a/newbrt/recover.c +++ b/newbrt/recover.c @@ -452,7 +452,7 @@ static void toku_recover_fopen (LSN UU(lsn), TXNID UU(txnid), BYTESTRING fname, FILENUM filenum) { char *fixedfname = fixup_fname(&fname); CACHEFILE cf; - int fd = open(fixedfname, O_RDWR, 0); + int fd = open(fixedfname, O_RDWR+O_BINARY, 0); assert(fd>=0); BRT brt=0; int r = toku_brt_create(&brt); @@ -701,7 +701,7 @@ int tokudb_recover(const char *data_dir, const char *log_dir) { char lockfname[namelen+20]; snprintf(lockfname, sizeof(lockfname), "%s/__recoverylock_dont_delete_me", data_dir); - lockfd = open(lockfname, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); + lockfd = open(lockfname, O_RDWR|O_CREAT|O_BINARY, S_IRUSR | S_IWUSR); if (lockfd<0) { printf("Couldn't open %s\n", lockfname); return errno; diff --git a/newbrt/roll.c b/newbrt/roll.c index 7988fec164d..5f20f9564e4 100644 --- a/newbrt/roll.c +++ b/newbrt/roll.c @@ -155,7 +155,7 @@ int toku_rollback_fileentries (int fd, toku_off_t filesize, TOKUTXN txn) { int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) { int r; char *fname = fixup_fname(&bs); - int fd = open(fname, O_RDONLY); + int fd = open(fname, O_RDONLY+O_BINARY); assert(fd>=0); struct stat statbuf; r = fstat(fd, &statbuf); @@ -172,7 +172,7 @@ int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) { int toku_rollback_rollinclude (BYTESTRING bs,TOKUTXN txn) { int r; char *fname = fixup_fname(&bs); - int fd = open(fname, O_RDONLY); + int fd = open(fname, O_RDONLY+O_BINARY); assert(fd>=0); struct stat statbuf; r = fstat(fd, &statbuf); diff --git a/newbrt/tests/bread-test.c b/newbrt/tests/bread-test.c index 78006c690c4..37dbe8ca78d 100644 --- a/newbrt/tests/bread-test.c +++ b/newbrt/tests/bread-test.c @@ -7,6 +7,7 @@ #include #include +#include "../brttypes.h" #include "../bread.h" #define FNAME "bread-test.data" @@ -21,16 +22,16 @@ test (int seed) { char buf[RECORDS][100]; int sizes[RECORDS]; int sizesn[RECORDS]; - size_t off = 0; + toku_off_t off = 0; { - int fd = creat(FNAME, 0777); + int fd = open(FNAME, O_CREAT+O_RDWR+O_BINARY, 0777); assert(fd>=0); for (i=0; i=0); + int fd = open(FNAME, O_RDONLY+O_BINARY); assert(fd>=0); // Now read it all backward BREAD br = create_bread_from_fd_initialize_at(fd, off, 50); while (bread_has_more(br)) { diff --git a/newbrt/tests/brt-serialize-test.c b/newbrt/tests/brt-serialize-test.c index 0c781b2ed4f..8e1940aeaed 100644 --- a/newbrt/tests/brt-serialize-test.c +++ b/newbrt/tests/brt-serialize-test.c @@ -7,7 +7,7 @@ static void test_serialize(void) { // struct brt source_brt; int nodesize = 1024; struct brtnode sn, *dn; - int fd = open(__FILE__ "brt", O_RDWR|O_CREAT, 0777); + int fd = open(__FILE__ "brt", O_RDWR|O_CREAT|O_BINARY, S_IRWXU|S_IRWXG|S_IRWXO); int r; const u_int32_t randval = random(); assert(fd>=0); diff --git a/newbrt/tests/cachetable-checkpoint-test.c b/newbrt/tests/cachetable-checkpoint-test.c index 3218b6c73df..2216b3d714d 100644 --- a/newbrt/tests/cachetable-checkpoint-test.c +++ b/newbrt/tests/cachetable-checkpoint-test.c @@ -34,7 +34,7 @@ void cachetable_checkpoint_test(int n, int dirty) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); // insert items into the cachetable. all should be dirty int i; diff --git a/newbrt/tests/cachetable-count-pinned-test.c b/newbrt/tests/cachetable-count-pinned-test.c index 336f8775347..9a6176add57 100644 --- a/newbrt/tests/cachetable-count-pinned-test.c +++ b/newbrt/tests/cachetable-count-pinned-test.c @@ -36,7 +36,7 @@ cachetable_count_pinned_test (int n) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); int i; for (i=1; i<=n; i++) { diff --git a/newbrt/tests/cachetable-debug-test.c b/newbrt/tests/cachetable-debug-test.c index b37aacb7734..a642dded9e6 100644 --- a/newbrt/tests/cachetable-debug-test.c +++ b/newbrt/tests/cachetable-debug-test.c @@ -36,7 +36,7 @@ cachetable_debug_test (int n) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); int num_entries, hash_size; long size_current, size_limit; toku_cachetable_get_state(ct, &num_entries, &hash_size, &size_current, &size_limit); diff --git a/newbrt/tests/cachetable-fd-test.c b/newbrt/tests/cachetable-fd-test.c index 804295c1457..34cc151f383 100644 --- a/newbrt/tests/cachetable-fd-test.c +++ b/newbrt/tests/cachetable-fd-test.c @@ -1,6 +1,7 @@ #include "includes.h" #include "test.h" + static void cachetable_fd_test (void) { const int test_limit = 1; @@ -10,21 +11,21 @@ cachetable_fd_test (void) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE cf; - r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); int fd1 = toku_cachefile_fd(cf); assert(fd1 >= 0); // test set to good fd succeeds char fname2[] = __FILE__ "test2.data"; unlink(fname2); - int fd2 = open(fname2, O_RDWR + O_CREAT); assert(fd2 >= 0 && fd1 != fd2); + int fd2 = open(fname2, O_RDWR | O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(fd2 >= 0 && fd1 != fd2); r = toku_cachefile_set_fd(cf, fd2, fname2); assert(r == 0); assert(toku_cachefile_fd(cf) == fd2); // test set to bogus fd fails - int fd3 = open("/dev/null", O_RDWR); assert(fd3 >= 0); + int fd3 = open(DEV_NULL_FILE, O_RDWR); assert(fd3 >= 0); r = close(fd3); assert(r == 0); - r = toku_cachefile_set_fd(cf, fd3, "/dev/null"); assert(r != 0); + r = toku_cachefile_set_fd(cf, fd3, DEV_NULL_FILE); assert(r != 0); assert(toku_cachefile_fd(cf) == fd2); // test the filenum functions @@ -44,6 +45,8 @@ cachetable_fd_test (void) { int main(int argc, const char *argv[]) { default_parse_args(argc, argv); + os_initialize_settings(verbose); + cachetable_fd_test(); return 0; } diff --git a/newbrt/tests/cachetable-flush-test.c b/newbrt/tests/cachetable-flush-test.c index e39267806b6..600273bcd06 100644 --- a/newbrt/tests/cachetable-flush-test.c +++ b/newbrt/tests/cachetable-flush-test.c @@ -36,12 +36,12 @@ test_cachetable_flush (int n) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); char fname2[] = __FILE__ "test2.dat"; unlink(fname2); CACHEFILE f2; - r = toku_cachetable_openf(&f2, ct, fname2, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f2, ct, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); // insert keys 0..n-1 int i; diff --git a/newbrt/tests/cachetable-getandpin-test.c b/newbrt/tests/cachetable-getandpin-test.c index 8b3e3017546..ea257ab5374 100644 --- a/newbrt/tests/cachetable-getandpin-test.c +++ b/newbrt/tests/cachetable-getandpin-test.c @@ -45,7 +45,7 @@ cachetable_getandpin_test (int n) { char fname1[] = __FILE__ "test_getandpin.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); int i; diff --git a/newbrt/tests/cachetable-put-test.c b/newbrt/tests/cachetable-put-test.c index d2a0e22fa7f..13a692d47b4 100644 --- a/newbrt/tests/cachetable-put-test.c +++ b/newbrt/tests/cachetable-put-test.c @@ -36,7 +36,7 @@ cachetable_put_test (int n) { char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; - r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0); + r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); int i; for (i=1; i<=n; i++) { diff --git a/newbrt/tests/cachetable-rename-test.c b/newbrt/tests/cachetable-rename-test.c index b4e942234fb..fe93f5ed448 100644 --- a/newbrt/tests/cachetable-rename-test.c +++ b/newbrt/tests/cachetable-rename-test.c @@ -83,7 +83,7 @@ static void test_rename (void) { const char fname[] = __FILE__ "rename.dat"; r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); - r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); + r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); for (i=0; i0 && rwritequeue, &rwfc->mutex); } r = toku_pthread_mutex_unlock(&rwfc->mutex); assert(r == 0); - // usleep(random() % 1); + // os_usleep(random() % 1); } writequeue_set_closed(&rwfc->writequeue); void *ret; diff --git a/newbrt/tests/log-test.c b/newbrt/tests/log-test.c index eded927b088..d0849359f37 100644 --- a/newbrt/tests/log-test.c +++ b/newbrt/tests/log-test.c @@ -11,22 +11,22 @@ int main (int argc __attribute__((__unused__)), int r; long long lognum; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); r = toku_logger_find_next_unused_log_file(dname,&lognum); assert(r==0 && lognum==0LL); - r = creat(dname "/log01.tokulog", 0700); assert(r>=0); + r = creat(dname "/log01.tokulog", S_IRWXU); assert(r>=0); r = close(r); assert(r==0); r = toku_logger_find_next_unused_log_file(dname,&lognum); assert(r==0 && lognum==2LL); - r = creat(dname "/log123456789012345.tokulog", 0700); assert(r>=0); + r = creat(dname "/log123456789012345.tokulog", S_IRWXU); assert(r>=0); r = close(r); assert(r==0); r = toku_logger_find_next_unused_log_file(dname,&lognum); assert(r==0 && lognum==123456789012346LL); - r = creat(dname "/log3.tokulog", 0700); assert(r>=0); + r = creat(dname "/log3.tokulog", S_IRWXU); assert(r>=0); r = close(r); assert(r==0); r = toku_logger_find_next_unused_log_file(dname,&lognum); assert(r==0 && lognum==123456789012346LL); diff --git a/newbrt/tests/log-test2.c b/newbrt/tests/log-test2.c index d53e750b5ef..2e76b0d6fd3 100644 --- a/newbrt/tests/log-test2.c +++ b/newbrt/tests/log-test2.c @@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int r; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); TOKULOGGER logger; r = toku_logger_create(&logger); assert(r == 0); diff --git a/newbrt/tests/log-test3.c b/newbrt/tests/log-test3.c index 3adb78a8627..c7f8029a8b5 100644 --- a/newbrt/tests/log-test3.c +++ b/newbrt/tests/log-test3.c @@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int r; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); TOKULOGGER logger; r = toku_logger_create(&logger); assert(r == 0); diff --git a/newbrt/tests/log-test4.c b/newbrt/tests/log-test4.c index d4cb32936a6..8b70fc4efdf 100644 --- a/newbrt/tests/log-test4.c +++ b/newbrt/tests/log-test4.c @@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int r; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); TOKULOGGER logger; r = toku_logger_create(&logger); assert(r == 0); diff --git a/newbrt/tests/log-test5.c b/newbrt/tests/log-test5.c index 1db633cae34..5ec14f0fa03 100644 --- a/newbrt/tests/log-test5.c +++ b/newbrt/tests/log-test5.c @@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int r; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); TOKULOGGER logger; r = toku_logger_create(&logger); assert(r == 0); diff --git a/newbrt/tests/log-test6.c b/newbrt/tests/log-test6.c index 9dc4b643398..5a93c4cbe43 100644 --- a/newbrt/tests/log-test6.c +++ b/newbrt/tests/log-test6.c @@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int r; system(rmrf); - r = mkdir(dname, 0700); assert(r==0); + r = os_mkdir(dname, S_IRWXU); assert(r==0); TOKULOGGER logger; r = toku_logger_create(&logger); assert(r == 0); diff --git a/newbrt/tests/test-del-inorder.c b/newbrt/tests/test-del-inorder.c index d46646efd48..79f65dd7962 100644 --- a/newbrt/tests/test-del-inorder.c +++ b/newbrt/tests/test-del-inorder.c @@ -5,7 +5,7 @@ static TOKUTXN const null_txn = 0; static DB * const null_db = 0; -enum { NODESIZE = 1024, KSIZE=NODESIZE-100, PSIZE=20 }; +enum { NODESIZE = 1024, KSIZE=NODESIZE-100, TOKU_PSIZE=20 }; CACHETABLE ct; BRT t; diff --git a/newbrt/tests/test-inc-split.c b/newbrt/tests/test-inc-split.c index 66198cb8421..2c890294cb6 100644 --- a/newbrt/tests/test-inc-split.c +++ b/newbrt/tests/test-inc-split.c @@ -31,7 +31,7 @@ static TOKUTXN const null_txn = 0; static DB * const null_db = 0; -enum { NODESIZE = 1024, KSIZE=NODESIZE-100, PSIZE=20 }; +enum { NODESIZE = 1024, KSIZE=NODESIZE-100, TOKU_PSIZE=20 }; CACHETABLE ct; BRT t; @@ -73,8 +73,8 @@ doit (int ksize __attribute__((__unused__))) { // Now we have a bunch of leaves, all of which are with 100 bytes of full. for (i=0; i+1 - +#include "brttypes.h" #include "leafentry.h" static void test_leafentry_1 (void) { diff --git a/newbrt/tests/test_oexcl.c b/newbrt/tests/test_oexcl.c index a55ae411d8c..ff05c9a795c 100644 --- a/newbrt/tests/test_oexcl.c +++ b/newbrt/tests/test_oexcl.c @@ -7,9 +7,9 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { unlink(fname); - int fd0 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777); + int fd0 = open (fname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO); assert(fd0>=0); - int fd1 = open (fname, O_RDWR|O_CREAT|O_EXCL, 0777); + int fd1 = open (fname, O_RDWR|O_CREAT|O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO); assert(fd1==-1); assert(errno==EEXIST); return 0; diff --git a/newbrt/tests/threadpool-test.c b/newbrt/tests/threadpool-test.c index e6b479245f3..4fa823b6afd 100644 --- a/newbrt/tests/threadpool-test.c +++ b/newbrt/tests/threadpool-test.c @@ -1,3 +1,5 @@ +#include "portability.h" +#include "os.h" #include #include #include @@ -51,7 +53,7 @@ fbusy (void *arg) { r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0); } r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0); - if (verbose) printf("%lu:%s:exit\n", toku_pthread_self(), __FUNCTION__); + if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__); return arg; } @@ -66,11 +68,15 @@ fidle (void *arg) { r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0); } r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0); - if (verbose) printf("%lu:%s:exit\n", toku_pthread_self(), __FUNCTION__); + if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__); return arg; } +#if defined(__linux__) #define DO_MALLOC_HOOK 1 +#else +#define DO_MALLOC_HOOK 0 +#endif #if DO_MALLOC_HOOK static void *my_malloc_always_fails(size_t n, const __malloc_ptr_t p) { n = n; p = p; @@ -88,7 +94,9 @@ usage (void) { int main(int argc, char *argv[]) { int max_threads = 1; +#if defined(__linux__) int do_malloc_fail = 0; +#endif int i; for (i=1; i