summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-01-31 14:58:24 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-01-31 14:58:24 +1100
commit26d8f2ca8fa0451c103d031a8c31c26cff1494f4 (patch)
tree7a8b203056abdfe6314288ab8707b12618c47de1
parent3faab64581680951334a83eba52334b505e6e338 (diff)
downloadmongo-26d8f2ca8fa0451c103d031a8c31c26cff1494f4.tar.gz
Handle errors from __wt_cursor_init.
refs #153
-rw-r--r--src/cursor/cur_config.c8
-rw-r--r--src/cursor/cur_file.c2
-rw-r--r--src/cursor/cur_index.c16
-rw-r--r--src/cursor/cur_stat.c2
-rw-r--r--src/cursor/cur_std.c1
-rw-r--r--src/cursor/cur_table.c6
-rw-r--r--src/include/extern.h2
7 files changed, 22 insertions, 15 deletions
diff --git a/src/cursor/cur_config.c b/src/cursor/cur_config.c
index eadbfa3ed5d..fd4cd883a68 100644
--- a/src/cursor/cur_config.c
+++ b/src/cursor/cur_config.c
@@ -55,6 +55,7 @@ __wt_curconfig_open(WT_SESSION_IMPL *session,
};
WT_CURSOR_CONFIG *cconfig;
WT_CURSOR *cursor;
+ int ret;
WT_UNUSED(uri);
@@ -66,8 +67,11 @@ __wt_curconfig_open(WT_SESSION_IMPL *session,
cursor->key_format = cursor->value_format = "S";
STATIC_ASSERT(offsetof(WT_CURSOR_CONFIG, iface) == 0);
- __wt_cursor_init(cursor, uri, 0, 1, cfg);
+ WT_ERR(__wt_cursor_init(cursor, uri, 0, 1, cfg));
*cursorp = cursor;
- return (0);
+ if (0) {
+err: __wt_free(session, cconfig);
+ }
+ return (ret);
}
diff --git a/src/cursor/cur_file.c b/src/cursor/cur_file.c
index 1c7f30cefbf..93c47947a0a 100644
--- a/src/cursor/cur_file.c
+++ b/src/cursor/cur_file.c
@@ -284,7 +284,7 @@ __wt_curfile_create(WT_SESSION_IMPL *session,
F_SET(cursor, WT_CURSTD_OVERWRITE);
STATIC_ASSERT(offsetof(WT_CURSOR_BTREE, iface) == 0);
- __wt_cursor_init(cursor, cursor->uri, 1, 0, cfg);
+ WT_ERR(__wt_cursor_init(cursor, cursor->uri, 1, 0, cfg));
*cursorp = cursor;
if (0) {
diff --git a/src/cursor/cur_index.c b/src/cursor/cur_index.c
index 475b4e005d7..76eee939c19 100644
--- a/src/cursor/cur_index.c
+++ b/src/cursor/cur_index.c
@@ -393,6 +393,7 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
namesize = (size_t)(columns - idxname);
WT_RET(__wt_schema_open_index(session, table, idxname, namesize));
+ WT_RET(__wt_session_lock_btree(session, NULL, 0));
WT_RET(__wt_calloc_def(session, 1, &cindex));
cbt = &cindex->cbt;
@@ -402,7 +403,6 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
cbt->btree = session->btree;
cindex->table = table;
- WT_RET(__wt_session_lock_btree(session, NULL, 0));
cindex->key_plan = session->btree->key_plan;
cindex->value_plan = session->btree->value_plan;
@@ -413,21 +413,25 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
/* Handle projections. */
if (columns != NULL) {
WT_CLEAR(fmt);
- WT_RET(__wt_struct_reformat(session, table,
+ WT_ERR(__wt_struct_reformat(session, table,
columns, strlen(columns), NULL, 0, &fmt));
cursor->value_format = __wt_buf_steal(session, &fmt, NULL);
WT_CLEAR(plan);
- WT_RET(__wt_struct_plan(session, table,
+ WT_ERR(__wt_struct_plan(session, table,
columns, strlen(columns), 0, &plan));
cindex->value_plan = __wt_buf_steal(session, &plan, NULL);
}
/* Open the column groups needed for this index cursor. */
- WT_RET(__curindex_open_colgroups(session, cindex, cfg));
+ WT_ERR(__curindex_open_colgroups(session, cindex, cfg));
- __wt_cursor_init(cursor, cursor->uri, 1, 1, cfg);
+ WT_ERR(__wt_cursor_init(cursor, cursor->uri, 1, 1, cfg));
*cursorp = cursor;
- return (0);
+ if (0) {
+err: (void)__curindex_close(cursor, NULL);
+ }
+
+ return (ret);
}
diff --git a/src/cursor/cur_stat.c b/src/cursor/cur_stat.c
index 33eaffd5908..502484f8a4c 100644
--- a/src/cursor/cur_stat.c
+++ b/src/cursor/cur_stat.c
@@ -387,7 +387,7 @@ __wt_curstat_open(WT_SESSION_IMPL *session,
F_SET(cursor, WT_CURSTD_RAW);
STATIC_ASSERT(offsetof(WT_CURSOR_STAT, iface) == 0);
- __wt_cursor_init(cursor, uri, 0, 1, cfg);
+ WT_ERR(__wt_cursor_init(cursor, uri, 0, 1, cfg));
/*
* We return the statistics field's offset as the key, and a string
diff --git a/src/cursor/cur_std.c b/src/cursor/cur_std.c
index 2db33394842..e1ef94a215d 100644
--- a/src/cursor/cur_std.c
+++ b/src/cursor/cur_std.c
@@ -320,6 +320,7 @@ err: API_END(session);
int
__wt_cursor_init(WT_CURSOR *cursor,
const char *uri, int is_file, int is_public, const char *cfg[])
+ WT_GCC_FUNC_ATTRIBUTE((warn_unused_result))
{
WT_SESSION_IMPL *session;
diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c
index d2ad1238a7b..d969f91035e 100644
--- a/src/cursor/cur_table.c
+++ b/src/cursor/cur_table.c
@@ -630,13 +630,11 @@ __wt_curtable_open(WT_SESSION_IMPL *session,
WT_ERR(__curtable_open_colgroups(ctable, cfg));
STATIC_ASSERT(offsetof(WT_CURSOR_TABLE, iface) == 0);
- __wt_cursor_init(cursor, cursor->uri, 0, 1, cfg);
+ WT_ERR(__wt_cursor_init(cursor, cursor->uri, 0, 1, cfg));
*cursorp = cursor;
if (0) {
-err: __wt_free(session, ctable);
- __wt_buf_free(session, &fmt);
- __wt_buf_free(session, &plan);
+err: (void)__curtable_close(cursor, NULL);
}
return (ret);
diff --git a/src/include/extern.h b/src/include/extern.h
index 1b17349227a..9a8096e8f6c 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -472,7 +472,7 @@ extern int __wt_cursor_init(WT_CURSOR *cursor,
const char *uri,
int is_file,
int is_public,
- const char *cfg[]);
+ const char *cfg[]) WT_GCC_ATTRIBUTE((warn_unused_result));
extern int __wt_cursor_kv_not_set(WT_CURSOR *cursor, int key);
extern int __wt_curtable_get_key(WT_CURSOR *cursor, ...);
extern int __wt_curtable_get_value(WT_CURSOR *cursor, ...);