summaryrefslogtreecommitdiff
path: root/src/async
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2014-05-06 11:27:01 -0400
committerSusan LoVerso <sue@wiredtiger.com>2014-05-06 11:27:01 -0400
commit1fcf74d1dd7c675b833ebad1effc355f043f4a29 (patch)
tree0cbc8cf7a7be6cc257418af68e1ef36fe2d1cbb3 /src/async
parent6a3c4397e3ee5d726f87627246f4ddc45dc71533 (diff)
downloadmongo-1fcf74d1dd7c675b833ebad1effc355f043f4a29.tar.gz
Lint.
Diffstat (limited to 'src/async')
-rw-r--r--src/async/async_api.c13
-rw-r--r--src/async/async_op.c35
-rw-r--r--src/async/async_worker.c30
3 files changed, 46 insertions, 32 deletions
diff --git a/src/async/async_api.c b/src/async/async_api.c
index 9a21e5e021a..963bb44baa7 100644
--- a/src/async/async_api.c
+++ b/src/async/async_api.c
@@ -22,11 +22,10 @@ __async_get_format(WT_CONNECTION_IMPL *conn, const char *uri,
WT_SESSION *wt_session;
WT_SESSION_IMPL *session;
uint64_t cfg_hash, uri_hash;
- int have_cursor;
async = conn->async;
+ c = NULL;
op->format = NULL;
- have_cursor = 0;
if (uri != NULL)
uri_hash = __wt_hash_city64(uri, strlen(uri));
@@ -66,11 +65,10 @@ __async_get_format(WT_CONNECTION_IMPL *conn, const char *uri,
*/
wt_session = &session->iface;
WT_ERR(wt_session->open_cursor(wt_session, uri, NULL, NULL, &c));
- have_cursor = 1;
WT_ERR(__wt_strdup(session, c->key_format, &af->key_format));
WT_ERR(__wt_strdup(session, c->value_format, &af->value_format));
WT_ERR(c->close(c));
- have_cursor = 0;
+ c = NULL;
STAILQ_INSERT_HEAD(&async->formatqh, af, q);
__wt_spin_unlock(session, &async->ops_lock);
@@ -89,8 +87,8 @@ setup: op->format = af;
return (0);
err:
- if (have_cursor)
- c->close(c);
+ if (c != NULL)
+ (void)c->close(c);
__wt_free(session, af->uri);
__wt_free(session, af->config);
__wt_free(session, af->key_format);
@@ -117,6 +115,7 @@ __async_new_op_alloc(WT_CONNECTION_IMPL *conn, const char *uri,
session = conn->default_session;
WT_STAT_FAST_CONN_INCR(conn->default_session, async_op_alloc);
*opp = NULL;
+ op = NULL;
retry:
ret = 0;
WT_ORDERED_READ(save_i, async->ops_index);
@@ -376,7 +375,7 @@ retry:
* things off the work queue with the lock.
*/
async->flush_count = 0;
- WT_ATOMIC_ADD(async->flush_gen, 1);
+ (void)WT_ATOMIC_ADD(async->flush_gen, 1);
WT_ASSERT(conn->default_session,
async->flush_op.state == WT_ASYNCOP_FREE);
async->flush_op.state = WT_ASYNCOP_READY;
diff --git a/src/async/async_op.c b/src/async/async_op.c
index 39b82085652..5aaf0ad4b2b 100644
--- a/src/async/async_op.c
+++ b/src/async/async_op.c
@@ -30,15 +30,18 @@ static void
__async_set_key(WT_ASYNC_OP *asyncop, ...)
{
WT_CURSOR *c;
+ WT_DECL_RET;
va_list ap;
c = &asyncop->c;
va_start(ap, asyncop);
__wt_cursor_set_keyv(c, c->flags, ap);
if (!WT_DATA_IN_ITEM(&c->key) && !WT_CURSOR_RECNO(c))
- __wt_buf_set(O2S((WT_ASYNC_OP_IMPL *)asyncop), &c->key,
- c->key.data, c->key.size);
+ WT_ERR(__wt_buf_set(O2S((WT_ASYNC_OP_IMPL *)asyncop), &c->key,
+ c->key.data, c->key.size));
va_end(ap);
+ if (0)
+err: c->saved_err = ret;
}
/*
@@ -65,6 +68,7 @@ static void
__async_set_value(WT_ASYNC_OP *asyncop, ...)
{
WT_CURSOR *c;
+ WT_DECL_RET;
va_list ap;
c = &asyncop->c;
@@ -72,9 +76,11 @@ __async_set_value(WT_ASYNC_OP *asyncop, ...)
__wt_cursor_set_valuev(c, ap);
/* Copy the data, if it is pointing at data elsewhere. */
if (!WT_DATA_IN_ITEM(&c->value))
- __wt_buf_set(O2S((WT_ASYNC_OP_IMPL *)asyncop),
- &c->value, c->value.data, c->value.size);
+ WT_ERR(__wt_buf_set(O2S((WT_ASYNC_OP_IMPL *)asyncop),
+ &c->value, c->value.data, c->value.size));
va_end(ap);
+ if (0)
+err: c->saved_err = ret;
}
/*
@@ -236,7 +242,7 @@ __async_op_init(WT_CONNECTION_IMPL *conn, WT_ASYNC_OP_IMPL *op, uint32_t id)
asyncop->c.get_value = __wt_cursor_get_value;
asyncop->c.set_value = __wt_cursor_set_value;
asyncop->c.recno = 0;
- memset(&asyncop->c.raw_recno_buf, 0, sizeof(asyncop->c.raw_recno_buf));
+ memset(asyncop->c.raw_recno_buf, 0, sizeof(asyncop->c.raw_recno_buf));
memset(&asyncop->c.key, 0, sizeof(asyncop->c.key));
memset(&asyncop->c.value, 0, sizeof(asyncop->c.value));
asyncop->c.session = (WT_SESSION *)conn->default_session;
@@ -286,7 +292,7 @@ __wt_async_op_enqueue(WT_CONNECTION_IMPL *conn, WT_ASYNC_OP_IMPL *op)
#ifdef HAVE_DIAGNOSTIC
WT_ORDERED_READ(my_op, async->async_queue[my_slot]);
if (my_op != NULL)
- __wt_panic(conn->default_session);
+ return (__wt_panic(conn->default_session));
#endif
WT_PUBLISH(async->async_queue[my_slot], op);
op->state = WT_ASYNCOP_ENQUEUED;
@@ -314,13 +320,14 @@ __wt_async_op_init(WT_CONNECTION_IMPL *conn)
{
WT_ASYNC *async;
WT_ASYNC_OP_IMPL *op;
+ WT_DECL_RET;
uint32_t i;
async = conn->async;
/*
* Initialize the flush op structure.
*/
- __async_op_init(conn, &async->flush_op, OPS_INVALID_INDEX);
+ WT_RET(__async_op_init(conn, &async->flush_op, OPS_INVALID_INDEX));
/*
* Allocate and initialize the work queue. This is sized so that
@@ -333,11 +340,21 @@ __wt_async_op_init(WT_CONNECTION_IMPL *conn)
/*
* Allocate and initialize all the user ops.
*/
- WT_RET(__wt_calloc_def(conn->default_session,
+ WT_ERR(__wt_calloc_def(conn->default_session,
conn->async_size, &async->async_ops));
for (i = 0; i < conn->async_size; i++) {
op = &async->async_ops[i];
- __async_op_init(conn, op, i);
+ WT_ERR(__async_op_init(conn, op, i));
}
return (0);
+err:
+ if (async->async_ops != NULL) {
+ __wt_free(conn->default_session, async->async_ops);
+ async->async_ops = NULL;
+ }
+ if (async->async_queue != NULL) {
+ __wt_free(conn->default_session, async->async_queue);
+ async->async_queue = NULL;
+ }
+ return (ret);
}
diff --git a/src/async/async_worker.c b/src/async/async_worker.c
index ada9f3bf9ba..1fb809d1424 100644
--- a/src/async/async_worker.c
+++ b/src/async/async_worker.c
@@ -36,7 +36,7 @@ retry:
WT_ORDERED_READ(last_consume, async->alloc_tail);
}
if (F_ISSET(conn, WT_CONN_PANIC))
- __wt_panic(session);
+ return (__wt_panic(session));
if (tries >= max_tries ||
async->flush_state == WT_ASYNC_FLUSHING)
return (0);
@@ -154,7 +154,6 @@ __async_worker_execop(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op,
WT_CURSOR *cursor)
{
WT_ASYNC_OP *asyncop;
- WT_DECL_RET;
WT_ITEM val;
WT_SESSION *wt_session;
@@ -164,42 +163,42 @@ __async_worker_execop(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op,
* If needed, also set the value.
*/
if (op->optype != WT_AOP_COMPACT) {
- __wt_cursor_get_raw_key(&asyncop->c, &val);
+ WT_RET(__wt_cursor_get_raw_key(&asyncop->c, &val));
__wt_cursor_set_raw_key(cursor, &val);
if (op->optype == WT_AOP_INSERT ||
op->optype == WT_AOP_UPDATE) {
- __wt_cursor_get_raw_value(&asyncop->c, &val);
+ WT_RET(__wt_cursor_get_raw_value(&asyncop->c, &val));
__wt_cursor_set_raw_value(cursor, &val);
}
}
switch (op->optype) {
case WT_AOP_COMPACT:
wt_session = &session->iface;
- WT_ERR(wt_session->compact(wt_session,
+ WT_RET(wt_session->compact(wt_session,
op->format->uri, op->format->config));
break;
case WT_AOP_INSERT:
case WT_AOP_UPDATE:
- WT_ERR(cursor->insert(cursor));
+ WT_RET(cursor->insert(cursor));
break;
case WT_AOP_REMOVE:
- WT_ERR(cursor->remove(cursor));
+ WT_RET(cursor->remove(cursor));
break;
case WT_AOP_SEARCH:
- WT_ERR(cursor->search(cursor));
+ WT_RET(cursor->search(cursor));
/*
* Get the value from the cursor and put it into
* the op for op->get_value.
*/
- __wt_cursor_get_raw_value(cursor, &val);
+ WT_RET(__wt_cursor_get_raw_value(cursor, &val));
__wt_cursor_set_raw_value(&asyncop->c, &val);
break;
+ case WT_AOP_NONE:
default:
- WT_ERR_MSG(session, EINVAL, "Unknown async optype %d\n",
+ WT_RET_MSG(session, EINVAL, "Unknown async optype %d\n",
op->optype);
}
-err:
- return (ret);
+ return (0);
}
/*
@@ -245,7 +244,7 @@ __async_worker_op(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op,
WT_TRET(wt_session->rollback_transaction(
wt_session, NULL));
F_CLR(&asyncop->c, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET);
- cursor->reset(cursor);
+ WT_TRET(cursor->reset(cursor));
}
/*
* After the callback returns, and the transaction resolved release
@@ -271,7 +270,6 @@ __wt_async_worker(void *arg)
WT_DECL_RET;
WT_SESSION_IMPL *session;
uint64_t flush_gen;
- uint32_t fc;
session = arg;
conn = S2C(session);
@@ -288,7 +286,7 @@ __wt_async_worker(void *arg)
*/
(void)__async_worker_op(session, op, &worker);
if (F_ISSET(conn, WT_CONN_PANIC))
- __wt_panic(session);
+ WT_ERR(__wt_panic(session));
} else if (async->flush_state == WT_ASYNC_FLUSHING) {
/*
* Worker flushing going on. Last worker to the party
@@ -297,7 +295,7 @@ __wt_async_worker(void *arg)
* the queue.
*/
WT_ORDERED_READ(flush_gen, async->flush_gen);
- if ((fc = WT_ATOMIC_ADD(async->flush_count, 1)) ==
+ if (WT_ATOMIC_ADD(async->flush_count, 1) ==
conn->async_workers) {
/*
* We're last. All workers accounted for so