Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc Cleanup/Minor Fixes from KVS TreeObject Work #1152

Merged
merged 8 commits into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bindings/lua/flux-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ int l_flux_kvs_put (lua_State *L)
json_object_put (o);
}
if (rc < 0)
return lua_pusherror (L, "kvsdir_put (%s): %s",
return lua_pusherror (L, "kvs_put (%s): %s",
key, (char *)flux_strerror (errno));

lua_pushboolean (L, true);
Expand Down
24 changes: 24 additions & 0 deletions src/common/libkvs/kvs_txn.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*****************************************************************************\
* Copyright (c) 2017 Lawrence Livermore National Security, LLC. Produced at
* the Lawrence Livermore National Laboratory (cf, AUTHORS, DISCLAIMER.LLNS).
* LLNL-CODE-658032 All rights reserved.
*
* This file is part of the Flux resource manager framework.
* For details, see https://github.com/flux-framework.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the license, or (at your option)
* any later version.
*
* Flux is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* See also: http://www.gnu.org/licenses/
\*****************************************************************************/

#if HAVE_CONFIG_H
#include "config.h"
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/modules/kvs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ commit_process_t commit_process (commit_t *c,
}

if (!(c->rootcpy = json_copy (rootdir))) {
const char *tmpref;
/* empty item_callback_list to prevent mistakes later */
while ((tmpref = zlist_pop (c->item_callback_list)));
c->errnum = ENOMEM;
return COMMIT_PROCESS_ERROR;
}
Expand Down
1 change: 0 additions & 1 deletion src/modules/kvs/fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ int fence_add_request_data (fence_t *f, json_t *ops)
for (i = 0; i < json_array_size (ops); i++) {
if ((op = json_array_get (ops, i)))
if (json_array_append (f->ops, op) < 0) {
json_decref (op);
errno = ENOMEM;
return -1;
}
Expand Down
10 changes: 6 additions & 4 deletions src/modules/kvs/test/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void commit_mgr_basic_tests (void)

ops = json_array ();
ops_append (ops, "key1", "1");

ok (fence_add_request_data (f, ops) == 0,
"fence_add_request_data add works");

Expand Down Expand Up @@ -472,7 +472,7 @@ void commit_basic_commit_process_test_multiple_fences (void)
"commit_mgr_create works");

create_ready_commit (cm, "fence1", "key1", "1", 0);
create_ready_commit (cm, "fence2", "key2", "2", 0);
create_ready_commit (cm, "fence2", "dir.key2", "2", 0);

ok ((c = commit_mgr_get_ready_commit (cm)) != NULL,
"commit_mgr_get_ready_commit returns ready commit");
Expand Down Expand Up @@ -508,7 +508,8 @@ void commit_basic_commit_process_test_multiple_fences (void)
ok (commit_iter_dirty_cache_entries (c, cache_count_cb, &count) == 0,
"commit_iter_dirty_cache_entries works for dirty cache entries");

ok (count == 1,
/* why two? 1 for root (new dir added), 1 for dir.key2 (a new dir) */
ok (count == 2,
"correct number of cache entries were dirty");

ok (commit_process (c, 1, rootref) == COMMIT_PROCESS_FINISHED,
Expand All @@ -518,7 +519,7 @@ void commit_basic_commit_process_test_multiple_fences (void)
"commit_get_newroot_ref returns != NULL when processing complete");

verify_value (cache, newroot, "key1", "1");
verify_value (cache, newroot, "key2", "2");
verify_value (cache, newroot, "dir.key2", "2");

commit_mgr_remove_commit (cm, c);

Expand Down Expand Up @@ -1607,6 +1608,7 @@ int main (int argc, char *argv[])
* "normal" situation and is tested throughout
*/
commit_process_error_callbacks ();
commit_process_error_callbacks_partway ();
commit_process_invalid_operation ();
commit_process_invalid_hash ();
commit_process_follow_link ();
Expand Down
4 changes: 2 additions & 2 deletions src/modules/kvs/test/fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ void ops_tests (void)
"initial fence_get_json_ops call works");

ops = json_array ();
json_array_append_new (ops, json_string ("A"));
json_array_append_new (ops, json_string ("B"));
json_array_append_new (ops, json_string ("A"));
json_array_append_new (ops, json_string ("B"));

ok (json_equal (ops, o) == true,
"fence_get_json_ops match");
Expand Down
10 changes: 10 additions & 0 deletions t/kvs/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef struct {
int nil_count;
int stable_count;
int last_val;
int errcount;
} thd_t;

static void signal_ready (void)
Expand Down Expand Up @@ -101,16 +102,19 @@ static int mt_watch_cb (const char *k, const char *json_str, void *arg, int errn

if (errnum != 0) {
log_errn (errnum, "%d: %s", t->n, __FUNCTION__);
t->errcount++;
return -1;
}
if (!(obj = json_loads (json_str, JSON_DECODE_ANY, NULL))) {
log_msg ("%d: %s failed to decode value", t->n, __FUNCTION__);
t->errcount++;
return -1;
}
val = json_integer_value (obj);
if (val == t->last_val) {
log_msg ("%d: %s: called with same value as last time: %d", t->n,
__FUNCTION__, val);
t->errcount++;
return -1;
}
t->last_val = val;
Expand All @@ -130,6 +134,7 @@ static int mt_watchnil_cb (const char *k, const char *json_str, void *arg, int e
thd_t *t = arg;
if (errnum != ENOENT) {
log_errn (errnum, "%d: %s", t->n, __FUNCTION__);
t->errcount++;
return -1;
}
t->nil_count++;
Expand All @@ -144,6 +149,7 @@ static int mt_watchstable_cb (const char *k, const char *json_ttr, void *arg, in

if (errnum != 0) {
log_errn (errnum, "%d: %s", t->n, __FUNCTION__);
t->errcount++;
return -1;
}
t->stable_count++;
Expand Down Expand Up @@ -254,6 +260,10 @@ void test_mt (int argc, char **argv)
for (i = 0; i < nthreads; i++) {
if ((rc = pthread_join (thd[i].tid, NULL)))
log_errn (rc, "pthread_join");
if (thd[i].errcount != 0) {
log_msg ("%d: error occurred inside callback function", i);
errors++;
}
if (thd[i].nil_count != 1) {
log_msg ("%d: nil callback called %d times (expected one)",
i, thd[i].nil_count);
Expand Down