diff options
| author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-06-14 19:38:15 +0000 |
|---|---|---|
| committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-06-14 19:38:15 +0000 |
| commit | 47e8c3d1d22018eaaa09f91dfd78addb49e0b49b (patch) | |
| tree | 2d24fbd1e6c03d438d267b737becc318ca6fbadf /test | |
| parent | 7aaeaaa054d1ac27a95c79984f7ca69ba739caae (diff) | |
| parent | 84429199fd94f8a8201c5aa77432a2557d326902 (diff) | |
Merge branch 'develop' into mongodb-3.6mongodb-3.5.9
Diffstat (limited to 'test')
| -rw-r--r-- | test/checkpoint/checkpointer.c | 23 | ||||
| -rw-r--r-- | test/checkpoint/test_checkpoint.c | 10 | ||||
| -rw-r--r-- | test/checkpoint/test_checkpoint.h | 10 | ||||
| -rw-r--r-- | test/checkpoint/workers.c | 21 | ||||
| -rw-r--r-- | test/cursor_order/cursor_order.c | 3 | ||||
| -rw-r--r-- | test/cursor_order/cursor_order.h | 2 | ||||
| -rw-r--r-- | test/cursor_order/cursor_order_ops.c | 35 | ||||
| -rw-r--r-- | test/fops/fops.c | 21 | ||||
| -rw-r--r-- | test/fops/t.c | 3 | ||||
| -rw-r--r-- | test/fops/thread.h | 2 | ||||
| -rw-r--r-- | test/format/backup.c | 6 | ||||
| -rw-r--r-- | test/format/compact.c | 6 | ||||
| -rw-r--r-- | test/format/format.h | 10 | ||||
| -rw-r--r-- | test/format/lrt.c | 4 | ||||
| -rw-r--r-- | test/format/ops.c | 32 | ||||
| -rw-r--r-- | test/format/util.c | 4 | ||||
| -rw-r--r-- | test/recovery/random-abort.c | 13 | ||||
| -rw-r--r-- | test/suite/test_cursor01.py | 1 | ||||
| -rw-r--r-- | test/thread/rw.c | 35 | ||||
| -rw-r--r-- | test/thread/t.c | 3 | ||||
| -rw-r--r-- | test/thread/thread.h | 2 | ||||
| -rw-r--r-- | test/windows/windows_shim.c | 23 |
22 files changed, 105 insertions, 164 deletions
diff --git a/test/checkpoint/checkpointer.c b/test/checkpoint/checkpointer.c index 634a8db9124..3135caa8cad 100644 --- a/test/checkpoint/checkpointer.c +++ b/test/checkpoint/checkpointer.c @@ -28,7 +28,7 @@ #include "test_checkpoint.h" -static void *checkpointer(void *); +static WT_THREAD_RET checkpointer(void *); static int compare_cursors( WT_CURSOR *, const char *, WT_CURSOR *, const char *); static int diagnose_key_error(WT_CURSOR *, int, WT_CURSOR *, int); @@ -39,35 +39,28 @@ static int verify_checkpoint(WT_SESSION *); * start_checkpoints -- * Responsible for creating the checkpoint thread. */ -int +void start_checkpoints(void) { - int ret; - - if ((ret = pthread_create( - &g.checkpoint_thread, NULL, checkpointer, NULL)) != 0) - return (log_print_err("pthread_create", ret, 1)); - return (0); + testutil_check(__wt_thread_create(NULL, + &g.checkpoint_thread, checkpointer, NULL)); } /* * end_checkpoints -- * Responsible for cleanly shutting down the checkpoint thread. */ -int +void end_checkpoints(void) { - void *thread_ret; - - return (pthread_join(g.checkpoint_thread, &thread_ret)); - + testutil_check(__wt_thread_join(NULL, g.checkpoint_thread)); } /* * checkpointer -- * Checkpoint thread start function. */ -static void * +static WT_THREAD_RET checkpointer(void *arg) { char tid[128]; @@ -78,7 +71,7 @@ checkpointer(void *arg) printf("checkpointer thread starting: tid: %s\n", tid); (void)real_checkpointer(); - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/checkpoint/test_checkpoint.c b/test/checkpoint/test_checkpoint.c index ca13c2bc4ec..cfe5ef1bad4 100644 --- a/test/checkpoint/test_checkpoint.c +++ b/test/checkpoint/test_checkpoint.c @@ -150,20 +150,14 @@ main(int argc, char *argv[]) break; } - if ((ret = start_checkpoints()) != 0) { - (void)log_print_err("Start checkpoints failed", ret, 1); - break; - } + start_checkpoints(); if ((ret = start_workers(ttype)) != 0) { (void)log_print_err("Start workers failed", ret, 1); break; } g.running = 0; - if ((ret = end_checkpoints()) != 0) { - (void)log_print_err("Start workers failed", ret, 1); - break; - } + end_checkpoints(); free(g.cookies); g.cookies = NULL; diff --git a/test/checkpoint/test_checkpoint.h b/test/checkpoint/test_checkpoint.h index 223b580c611..36551211b7e 100644 --- a/test/checkpoint/test_checkpoint.h +++ b/test/checkpoint/test_checkpoint.h @@ -64,12 +64,12 @@ typedef struct { int running; /* Whether to stop */ int status; /* Exit status */ COOKIE *cookies; /* Per-thread info */ - pthread_t checkpoint_thread; /* Checkpoint thread */ + wt_thread_t checkpoint_thread; /* Checkpoint thread */ } GLOBAL; extern GLOBAL g; -int end_checkpoints(void); -int log_print_err(const char *, int, int); -int start_checkpoints(void); -int start_workers(table_type); +void end_checkpoints(void); +int log_print_err(const char *, int, int); +void start_checkpoints(void); +int start_workers(table_type); const char *type_to_string(table_type); diff --git a/test/checkpoint/workers.c b/test/checkpoint/workers.c index 520266adf55..724475926ee 100644 --- a/test/checkpoint/workers.c +++ b/test/checkpoint/workers.c @@ -29,7 +29,7 @@ #include "test_checkpoint.h" static int real_worker(void); -static void *worker(void *); +static WT_THREAD_RET worker(void *); /* * create_table -- @@ -64,9 +64,8 @@ start_workers(table_type type) WT_SESSION *session; struct timeval start, stop; double seconds; - pthread_t *tids; + wt_thread_t *tids; int i, ret; - void *thread_ret; ret = 0; @@ -98,17 +97,13 @@ start_workers(table_type type) (void)gettimeofday(&start, NULL); /* Create threads. */ - for (i = 0; i < g.nworkers; ++i) { - if ((ret = pthread_create( - &tids[i], NULL, worker, &g.cookies[i])) != 0) { - (void)log_print_err("pthread_create", ret, 1); - goto err; - } - } + for (i = 0; i < g.nworkers; ++i) + testutil_check(__wt_thread_create( + NULL, &tids[i], worker, &g.cookies[i])); /* Wait for the threads. */ for (i = 0; i < g.nworkers; ++i) - (void)pthread_join(tids[i], &thread_ret); + testutil_check(__wt_thread_join(NULL, tids[i])); (void)gettimeofday(&stop, NULL); seconds = (stop.tv_sec - start.tv_sec) + @@ -146,7 +141,7 @@ worker_op(WT_CURSOR *cursor, uint64_t keyno, u_int new_val) * worker -- * Worker thread start function. */ -static void * +static WT_THREAD_RET worker(void *arg) { char tid[128]; @@ -157,7 +152,7 @@ worker(void *arg) printf("worker thread starting: tid: %s\n", tid); (void)real_worker(); - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/cursor_order/cursor_order.c b/test/cursor_order/cursor_order.c index 2cbca9baf0e..336ee54db63 100644 --- a/test/cursor_order/cursor_order.c +++ b/test/cursor_order/cursor_order.c @@ -158,8 +158,7 @@ main(int argc, char *argv[]) wt_connect(cfg, config_open); /* WiredTiger connection */ - if (ops_start(cfg)) - return (EXIT_FAILURE); + ops_start(cfg); wt_shutdown(cfg); /* WiredTiger shut down */ } diff --git a/test/cursor_order/cursor_order.h b/test/cursor_order/cursor_order.h index 4f9240f77e8..ab9f94850df 100644 --- a/test/cursor_order/cursor_order.h +++ b/test/cursor_order/cursor_order.h @@ -50,5 +50,5 @@ typedef struct { } SHARED_CONFIG; void load(SHARED_CONFIG *, const char *); -int ops_start(SHARED_CONFIG *); +void ops_start(SHARED_CONFIG *); void verify(SHARED_CONFIG *, const char *); diff --git a/test/cursor_order/cursor_order_ops.c b/test/cursor_order/cursor_order_ops.c index 5c6cfe363b6..cdd5af1a9ef 100644 --- a/test/cursor_order/cursor_order_ops.c +++ b/test/cursor_order/cursor_order_ops.c @@ -28,9 +28,9 @@ #include "cursor_order.h" -static void *append_insert(void *); +static WT_THREAD_RET append_insert(void *); static void print_stats(SHARED_CONFIG *); -static void *reverse_scan(void *); +static WT_THREAD_RET reverse_scan(void *); typedef struct { char *name; /* object name */ @@ -45,15 +45,13 @@ typedef struct { static INFO *run_info; -int +void ops_start(SHARED_CONFIG *cfg) { struct timeval start, stop; double seconds; - pthread_t *tids; + wt_thread_t *tids; uint64_t i, name_index, offset, total_nops; - int ret; - void *thread_ret; tids = NULL; /* Keep GCC 4.1 happy. */ total_nops = 0; @@ -114,18 +112,15 @@ ops_start(SHARED_CONFIG *cfg) /* Create threads. */ for (i = 0; i < cfg->reverse_scanners; ++i) - if ((ret = pthread_create( - &tids[i], NULL, reverse_scan, (void *)(uintptr_t)i)) != 0) - testutil_die(ret, "pthread_create"); - for (; i < cfg->reverse_scanners + cfg->append_inserters; ++i) { - if ((ret = pthread_create( - &tids[i], NULL, append_insert, (void *)(uintptr_t)i)) != 0) - testutil_die(ret, "pthread_create"); - } + testutil_check(__wt_thread_create(NULL, + &tids[i], reverse_scan, (void *)(uintptr_t)i)); + for (; i < cfg->reverse_scanners + cfg->append_inserters; ++i) + testutil_check(__wt_thread_create(NULL, + &tids[i], append_insert, (void *)(uintptr_t)i)); /* Wait for the threads. */ for (i = 0; i < cfg->reverse_scanners + cfg->append_inserters; ++i) - (void)pthread_join(tids[i], &thread_ret); + testutil_check(__wt_thread_join(NULL, tids[i])); (void)gettimeofday(&stop, NULL); seconds = (stop.tv_sec - start.tv_sec) + @@ -154,8 +149,6 @@ ops_start(SHARED_CONFIG *cfg) free(run_info); free(tids); - - return (0); } /* @@ -217,7 +210,7 @@ reverse_scan_op( * reverse_scan -- * Reader thread start function. */ -static void * +static WT_THREAD_RET reverse_scan(void *arg) { INFO *s; @@ -260,7 +253,7 @@ reverse_scan(void *arg) /* Notify all other threads to finish once the first thread is done */ cfg->thread_finish = true; - return (NULL); + return (WT_THREAD_RET_VALUE); } /* @@ -307,7 +300,7 @@ append_insert_op( * append_insert -- * Writer thread start function. */ -static void * +static WT_THREAD_RET append_insert(void *arg) { INFO *s; @@ -347,7 +340,7 @@ append_insert(void *arg) /* Notify all other threads to finish once the first thread is done */ cfg->thread_finish = true; - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/fops/fops.c b/test/fops/fops.c index 571b7dd59fa..911bfba55ad 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -28,7 +28,7 @@ #include "thread.h" -static void *fop(void *); +static WT_THREAD_RET fop(void *); static void print_stats(u_int); typedef struct { @@ -46,15 +46,13 @@ typedef struct { static STATS *run_stats; -int +void fop_start(u_int nthreads) { struct timeval start, stop; double seconds; - pthread_t *tids; + wt_thread_t *tids; u_int i; - int ret; - void *thread_ret; tids = NULL; /* Silence GCC 4.1 warning. */ @@ -66,13 +64,12 @@ fop_start(u_int nthreads) /* Create threads. */ for (i = 0; i < nthreads; ++i) - if ((ret = pthread_create( - &tids[i], NULL, fop, (void *)(uintptr_t)i)) != 0) - testutil_die(ret, "pthread_create"); + testutil_check(__wt_thread_create( + NULL, &tids[i], fop, (void *)(uintptr_t)i)); /* Wait for the threads. */ for (i = 0; i < nthreads; ++i) - (void)pthread_join(tids[i], &thread_ret); + testutil_check(__wt_thread_join(NULL, tids[i])); (void)gettimeofday(&stop, NULL); seconds = (stop.tv_sec - start.tv_sec) + @@ -84,15 +81,13 @@ fop_start(u_int nthreads) free(run_stats); free(tids); - - return (0); } /* * fop -- * File operation function. */ -static void * +static WT_THREAD_RET fop(void *arg) { STATS *s; @@ -150,7 +145,7 @@ fop(void *arg) break; } - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/fops/t.c b/test/fops/t.c index a481c9ff1c4..2357b170e49 100644 --- a/test/fops/t.c +++ b/test/fops/t.c @@ -129,8 +129,7 @@ main(int argc, char *argv[]) wt_startup(config_open); - if (fop_start(nthreads)) - return (EXIT_FAILURE); + fop_start(nthreads); wt_shutdown(); printf("\n"); diff --git a/test/fops/thread.h b/test/fops/thread.h index 9c1fb0150a6..f6b6bdffd63 100644 --- a/test/fops/thread.h +++ b/test/fops/thread.h @@ -39,7 +39,7 @@ extern const char *config; /* Object config */ extern pthread_rwlock_t single; /* Single-thread */ -int fop_start(u_int); +void fop_start(u_int); void obj_bulk(void); void obj_bulk_unique(int); void obj_checkpoint(void); diff --git a/test/format/backup.c b/test/format/backup.c index ce8b8fed6bd..47f3c54325f 100644 --- a/test/format/backup.c +++ b/test/format/backup.c @@ -83,7 +83,7 @@ copy_file(WT_SESSION *session, const char *name) * backup -- * Periodically do a backup and verify it. */ -void * +WT_THREAD_RET backup(void *arg) { WT_CONNECTION *conn; @@ -100,7 +100,7 @@ backup(void *arg) /* Backups aren't supported for non-standard data sources. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) - return (NULL); + return (WT_THREAD_RET_VALUE); /* Open a session. */ testutil_check(conn->open_session(conn, NULL, NULL, &session)); @@ -188,5 +188,5 @@ backup(void *arg) testutil_check(session->close(session, NULL)); - return (NULL); + return (WT_THREAD_RET_VALUE); } diff --git a/test/format/compact.c b/test/format/compact.c index 00aed4c10f0..f2fa7521946 100644 --- a/test/format/compact.c +++ b/test/format/compact.c @@ -32,7 +32,7 @@ * compaction -- * Periodically do a compaction operation. */ -void * +WT_THREAD_RET compact(void *arg) { WT_CONNECTION *conn; @@ -44,7 +44,7 @@ compact(void *arg) /* Compaction isn't supported for all data sources. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) - return (NULL); + return (WT_THREAD_RET_VALUE); /* Open a session. */ conn = g.wts_conn; @@ -70,5 +70,5 @@ compact(void *arg) testutil_check(session->close(session, NULL)); - return (NULL); + return (WT_THREAD_RET_VALUE); } diff --git a/test/format/format.h b/test/format/format.h index 104ee1553f4..602c1cc6d59 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -259,7 +259,7 @@ typedef struct { uint64_t deadlock; int id; /* simple thread ID */ - pthread_t tid; /* thread ID */ + wt_thread_t tid; /* thread ID */ int quit; /* thread should quit */ @@ -279,9 +279,9 @@ void bdb_remove(uint64_t, int *); void bdb_update(const void *, size_t, const void *, size_t); #endif -void *alter(void *); -void *backup(void *); -void *compact(void *); +WT_THREAD_RET alter(void *); +WT_THREAD_RET backup(void *); +WT_THREAD_RET compact(void *); void config_clear(void); void config_error(void); void config_file(const char *); @@ -293,7 +293,7 @@ void key_gen(WT_ITEM *, uint64_t); void key_gen_insert(WT_RAND_STATE *, WT_ITEM *, uint64_t); void key_gen_setup(WT_ITEM *); void key_len_setup(void); -void *lrt(void *); +WT_THREAD_RET lrt(void *); void path_setup(const char *); int read_row(WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t); uint32_t rng(WT_RAND_STATE *); diff --git a/test/format/lrt.c b/test/format/lrt.c index 4af9d66d0e1..b9622cdb635 100644 --- a/test/format/lrt.c +++ b/test/format/lrt.c @@ -32,7 +32,7 @@ * lrt -- * Start a long-running transaction. */ -void * +WT_THREAD_RET lrt(void *arg) { WT_CONNECTION *conn; @@ -182,5 +182,5 @@ lrt(void *arg) free(value.mem); free(buf); - return (NULL); + return (WT_THREAD_RET_VALUE); } diff --git a/test/format/ops.c b/test/format/ops.c index 02cce77eec2..a5e761d53a4 100644 --- a/test/format/ops.c +++ b/test/format/ops.c @@ -36,7 +36,7 @@ static int col_reserve(WT_CURSOR *, uint64_t, bool); static int col_update( TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t, bool); static int nextprev(WT_CURSOR *, int); -static void *ops(void *); +static WT_THREAD_RET ops(void *); static int row_insert( TINFO *, WT_CURSOR *, WT_ITEM *, WT_ITEM *, uint64_t, bool); static int row_modify( @@ -62,7 +62,7 @@ wts_ops(int lastrun) TINFO **tinfo_list, *tinfo, total; WT_CONNECTION *conn; WT_SESSION *session; - pthread_t alter_tid, backup_tid, compact_tid, lrt_tid; + wt_thread_t alter_tid, backup_tid, compact_tid, lrt_tid; int64_t fourths, thread_ops; uint32_t i; int running; @@ -121,7 +121,8 @@ wts_ops(int lastrun) tinfo_list[i] = tinfo = dcalloc(1, sizeof(TINFO)); tinfo->id = (int)i + 1; tinfo->state = TINFO_RUNNING; - testutil_check(pthread_create(&tinfo->tid, NULL, ops, tinfo)); + testutil_check( + __wt_thread_create(NULL, &tinfo->tid, ops, tinfo)); } /* @@ -129,14 +130,16 @@ wts_ops(int lastrun) * long-running reader threads. */ if (g.c_alter) - testutil_check(pthread_create(&alter_tid, NULL, alter, NULL)); + testutil_check( + __wt_thread_create(NULL, &alter_tid, alter, NULL)); if (g.c_backups) - testutil_check(pthread_create(&backup_tid, NULL, backup, NULL)); + testutil_check( + __wt_thread_create(NULL, &backup_tid, backup, NULL)); if (g.c_compact) testutil_check( - pthread_create(&compact_tid, NULL, compact, NULL)); + __wt_thread_create(NULL, &compact_tid, compact, NULL)); if (!SINGLETHREADED && g.c_long_running_txn) - testutil_check(pthread_create(&lrt_tid, NULL, lrt, NULL)); + testutil_check(__wt_thread_create(NULL, &lrt_tid, lrt, NULL)); /* Spin on the threads, calculating the totals. */ for (;;) { @@ -158,7 +161,8 @@ wts_ops(int lastrun) break; case TINFO_COMPLETE: tinfo->state = TINFO_JOINED; - (void)pthread_join(tinfo->tid, NULL); + testutil_check( + __wt_thread_join(NULL, tinfo->tid)); break; case TINFO_JOINED: break; @@ -196,13 +200,13 @@ wts_ops(int lastrun) /* Wait for the backup, compaction, long-running reader threads. */ g.workers_finished = 1; if (g.c_alter) - (void)pthread_join(alter_tid, NULL); + testutil_check(__wt_thread_join(NULL, alter_tid)); if (g.c_backups) - (void)pthread_join(backup_tid, NULL); + testutil_check(__wt_thread_join(NULL, backup_tid)); if (g.c_compact) - (void)pthread_join(compact_tid, NULL); + testutil_check(__wt_thread_join(NULL, compact_tid)); if (!SINGLETHREADED && g.c_long_running_txn) - (void)pthread_join(lrt_tid, NULL); + testutil_check(__wt_thread_join(NULL, lrt_tid)); g.workers_finished = 0; if (g.logging != 0) { @@ -404,7 +408,7 @@ snap_check(WT_CURSOR *cursor, * ops -- * Per-thread operations. */ -static void * +static WT_THREAD_RET ops(void *arg) { enum { INSERT, MODIFY, READ, REMOVE, UPDATE } op; @@ -864,7 +868,7 @@ deadlock: ++tinfo->deadlock; free(value->mem); tinfo->state = TINFO_COMPLETE; - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/format/util.c b/test/format/util.c index 06e3f37b830..f09bb160893 100644 --- a/test/format/util.c +++ b/test/format/util.c @@ -472,7 +472,7 @@ fclose_and_clear(FILE **fpp) * alter -- * Periodically alter a table's metadata. */ -void * +WT_THREAD_RET alter(void *arg) { WT_CONNECTION *conn; @@ -510,5 +510,5 @@ alter(void *arg) } testutil_check(session->close(session, NULL)); - return (NULL); + return (WT_THREAD_RET_VALUE); } diff --git a/test/recovery/random-abort.c b/test/recovery/random-abort.c index 12f86d664ef..7e76f61bd12 100644 --- a/test/recovery/random-abort.c +++ b/test/recovery/random-abort.c @@ -69,7 +69,7 @@ typedef struct { uint32_t id; } WT_THREAD_DATA; -static void * +static WT_THREAD_RET thread_run(void *arg) { FILE *fp; @@ -161,15 +161,15 @@ static void fill_db(uint32_t) static void fill_db(uint32_t nth) { - pthread_t *thr; WT_CONNECTION *conn; WT_SESSION *session; WT_THREAD_DATA *td; + wt_thread_t *thr; uint32_t i; int ret; const char *envconf; - thr = dcalloc(nth, sizeof(pthread_t)); + thr = dcalloc(nth, sizeof(*thr)); td = dcalloc(nth, sizeof(WT_THREAD_DATA)); if (chdir(home) != 0) testutil_die(errno, "Child chdir: %s", home); @@ -192,9 +192,8 @@ fill_db(uint32_t nth) td[i].conn = conn; td[i].start = (UINT64_MAX / nth) * i; td[i].id = i; - if ((ret = pthread_create( - &thr[i], NULL, thread_run, &td[i])) != 0) - testutil_die(ret, "pthread_create"); + testutil_check(__wt_thread_create( + NULL, &thr[i], thread_run, &td[i])); } printf("Spawned %" PRIu32 " writer threads\n", nth); fflush(stdout); @@ -203,7 +202,7 @@ fill_db(uint32_t nth) * it is killed. */ for (i = 0; i < nth; ++i) - testutil_assert(pthread_join(thr[i], NULL) == 0); + testutil_check(__wt_thread_join(NULL, thr[i])); /* * NOTREACHED */ diff --git a/test/suite/test_cursor01.py b/test/suite/test_cursor01.py index 41b017aa882..99bdb6182c7 100644 --- a/test/suite/test_cursor01.py +++ b/test/suite/test_cursor01.py @@ -99,6 +99,7 @@ class test_cursor01(wttest.WiredTigerTestCase): self.pr('creating cursor') cursor = self.session.open_cursor(tablearg, None, None) self.assertCursorHasNoKeyValue(cursor) + self.assertEqual(cursor.uri, tablearg) for i in range(0, self.nentries): cursor[self.genkey(i)] = self.genvalue(i) diff --git a/test/thread/rw.c b/test/thread/rw.c index cbbd806c559..3283f780b32 100644 --- a/test/thread/rw.c +++ b/test/thread/rw.c @@ -29,8 +29,8 @@ #include "thread.h" static void print_stats(u_int); -static void *reader(void *); -static void *writer(void *); +static WT_THREAD_RET reader(void *); +static WT_THREAD_RET writer(void *); typedef struct { char *name; /* object name */ @@ -45,15 +45,13 @@ typedef struct { static INFO *run_info; -int +void rw_start(u_int readers, u_int writers) { struct timeval start, stop; + wt_thread_t *tids; double seconds; - pthread_t *tids; u_int i, name_index, offset, total_nops; - int ret; - void *thread_ret; tids = NULL; /* Keep GCC 4.1 happy. */ total_nops = 0; @@ -109,18 +107,15 @@ rw_start(u_int readers, u_int writers) /* Create threads. */ for (i = 0; i < readers; ++i) - if ((ret = pthread_create( - &tids[i], NULL, reader, (void *)(uintptr_t)i)) != 0) - testutil_die(ret, "pthread_create"); - for (; i < readers + writers; ++i) { - if ((ret = pthread_create( - &tids[i], NULL, writer, (void *)(uintptr_t)i)) != 0) - testutil_die(ret, "pthread_create"); - } + testutil_check(__wt_thread_create( + NULL, &tids[i], reader, (void *)(uintptr_t)i)); + for (; i < readers + writers; ++i) + testutil_check(__wt_thread_create( + NULL, &tids[i], writer, (void *)(uintptr_t)i)); /* Wait for the threads. */ for (i = 0; i < readers + writers; ++i) - (void)pthread_join(tids[i], &thread_ret); + testutil_check(__wt_thread_join(NULL, tids[i])); (void)gettimeofday(&stop, NULL); seconds = (stop.tv_sec - start.tv_sec) + @@ -147,8 +142,6 @@ rw_start(u_int readers, u_int writers) free(run_info); free(tids); - - return (0); } /* @@ -186,7 +179,7 @@ reader_op(WT_SESSION *session, WT_CURSOR *cursor, INFO *s) * reader -- * Reader thread start function. */ -static void * +static WT_THREAD_RET reader(void *arg) { INFO *s; @@ -234,7 +227,7 @@ reader(void *arg) printf(" read thread %2d stopping: tid: %s, file: %s\n", id, tid, s->name); - return (NULL); + return (WT_THREAD_RET_VALUE); } /* @@ -291,7 +284,7 @@ writer_op(WT_SESSION *session, WT_CURSOR *cursor, INFO *s) * writer -- * Writer thread start function. */ -static void * +static WT_THREAD_RET writer(void *arg) { INFO *s; @@ -339,7 +332,7 @@ writer(void *arg) printf("write thread %2d stopping: tid: %s, file: %s\n", id, tid, s->name); - return (NULL); + return (WT_THREAD_RET_VALUE); } /* diff --git a/test/thread/t.c b/test/thread/t.c index 4b767e7f476..c6ff9a95145 100644 --- a/test/thread/t.c +++ b/test/thread/t.c @@ -160,8 +160,7 @@ main(int argc, char *argv[]) wt_connect(config_open); /* WiredTiger connection */ - if (rw_start(readers, writers)) /* Loop operations */ - return (EXIT_FAILURE); + rw_start(readers, writers); /* Loop operations */ stats(); /* Statistics */ diff --git a/test/thread/thread.h b/test/thread/thread.h index 86b1b55a30e..bcba442b4c1 100644 --- a/test/thread/thread.h +++ b/test/thread/thread.h @@ -46,6 +46,6 @@ extern int vary_nops; /* Operations per thread */ extern int session_per_op; /* New session per operation */ void load(const char *); -int rw_start(u_int, u_int); +void rw_start(u_int, u_int); void stats(void); void verify(const char *); diff --git a/test/windows/windows_shim.c b/test/windows/windows_shim.c index 33980260dc6..8986c1a5ae1 100644 --- a/test/windows/windows_shim.c +++ b/test/windows/windows_shim.c @@ -124,26 +124,3 @@ pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) return (0); } - -#pragma warning( once : 4024 ) -#pragma warning( once : 4047 ) -int -pthread_create(pthread_t *tidret, const pthread_attr_t *ignored, - void *(*func)(void *), void * arg) -{ - ignored = ignored; - *tidret = CreateThread(NULL, 0, func, arg, 0, NULL); - - if (*tidret != NULL) - return (0); - - return (1); -} - -int -pthread_join(pthread_t thread, void **ignored) -{ - ignored = ignored; - WaitForSingleObject(thread, INFINITE); - return (0); -} |
