diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2014-04-10 15:04:20 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2014-04-10 15:04:20 -0400 |
commit | d0415669c3f88febc78a743b51e6d307d4d7a478 (patch) | |
tree | df9006fa210dc66132d250dd4fcae3f19399e04a /src/async | |
parent | 6d0ff7adb4a9cfee9edd446aac6fe94abbb1cb06 (diff) | |
download | mongo-d0415669c3f88febc78a743b51e6d307d4d7a478.tar.gz |
Comments and minor cleanup.
Diffstat (limited to 'src/async')
-rw-r--r-- | src/async/async_api.c | 16 | ||||
-rw-r--r-- | src/async/async_worker.c | 24 |
2 files changed, 28 insertions, 12 deletions
diff --git a/src/async/async_api.c b/src/async/async_api.c index c4676c59969..927e15296bc 100644 --- a/src/async/async_api.c +++ b/src/async/async_api.c @@ -109,7 +109,6 @@ __async_insert(WT_ASYNC_OP *asyncop) op = (WT_ASYNC_OP_IMPL *)asyncop; ASYNCOP_API_CALL(O2C(op), session, insert); - WT_STAT_FAST_CONN_INCR(O2S(op), async_op_insert); WT_ERR(__async_op_wrap(op, WT_AOP_INSERT)); err: API_END(session); @@ -235,10 +234,9 @@ __wt_async_op_enqueue(WT_CONNECTION_IMPL *conn, __wt_spin_unlock(conn->default_session, &async->opsq_lock); WT_ERR(__wt_cond_signal(conn->default_session, async->ops_cond)); /* - * Lock again if we need to for the caller. + * Relock if we need to for the caller. */ -err: - if (locked) +err: if (locked) __wt_spin_lock(conn->default_session, &async->opsq_lock); return (ret); } @@ -255,8 +253,14 @@ __wt_async_op_init(WT_CONNECTION_IMPL *conn) uint32_t i; async = conn->async; - op = &async->flush_op; - __async_op_init(conn, op, OPS_INVALID_INDEX); + /* + * Initialize the flush op structure. + */ + __async_op_init(conn, &async->flush_op, OPS_INVALID_INDEX); + + /* + * Allocate and initialize all the user ops. + */ WT_RET(__wt_calloc_def(conn->default_session, conn->async_size, &async->async_ops)); for (i = 0; i < conn->async_size; i++) { diff --git a/src/async/async_worker.c b/src/async/async_worker.c index a949141a751..ed3262c603b 100644 --- a/src/async/async_worker.c +++ b/src/async/async_worker.c @@ -17,6 +17,11 @@ __async_flush_wait(WT_SESSION_IMPL *session, WT_ASYNC *async, int *locked) { WT_DECL_RET; + /* + * We change the caller's locked setting so that if we return an + * error from this function the caller can properly unlock or not + * as needed. + */ while (FLD_ISSET(async->opsq_flush, WT_ASYNC_FLUSHING)) { __wt_spin_unlock(session, &async->opsq_lock); *locked= 0; @@ -33,7 +38,7 @@ err: return (ret); * Return a cursor for the worker thread to use for its op. * The worker thread caches cursors. So first search for one * with the same config/uri signature. Otherwise open a new - * cursor. + * cursor and cache it. */ static int __async_worker_cursor(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, @@ -50,6 +55,10 @@ __async_worker_cursor(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, STAILQ_FOREACH(ac, &worker->cursorqh, q) { if (op->format->cfg_hash == ac->cfg_hash && op->format->uri_hash == ac->uri_hash) { + /* + * If one of our cached cursors has a matching + * signature, use it and we're done. + */ *cursorp = ac->c; return (0); } @@ -69,8 +78,7 @@ __async_worker_cursor(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, *cursorp = c; return (0); -err: - __wt_free(session, ac); +err: __wt_free(session, ac); return (ret); } @@ -87,6 +95,10 @@ __async_worker_execop(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, WT_ITEM val; asyncop = (WT_ASYNC_OP *)op; + /* + * Set the key of our local cursor from the async op handle. + * If needed, also set the value. + */ __wt_cursor_set_raw_key(cursor, &asyncop->c.key); if (op->optype != WT_AOP_SEARCH) __wt_cursor_set_raw_value(cursor, &asyncop->c.value); @@ -152,7 +164,7 @@ __async_worker_op(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, else WT_TRET(__wt_txn_rollback(session, NULL)); /* - * After the callback returns, and the transaction resolved released + * After the callback returns, and the transaction resolved release * the op back to the free pool and reset our cached cursor. */ ret = 0; @@ -198,9 +210,9 @@ __wt_async_worker(void *arg) if (++async->flush_count == conn->async_workers) { /* * We're last. All workers accounted for so - * signal the condition and clear the flushing + * signal the condition and clear the FLUSHING * flag to release the other worker threads. - * Set the complete flag so that the + * Set the FLUSH_COMPLETE flag so that the * caller can return to the application. */ FLD_SET(async->opsq_flush, |