From e26522bdc6c620e7b62a140aa4320735fbe32734 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Thu, 3 Jan 2013 14:16:33 +1030 Subject: [PATCH] Minor improvements to command line time measurements --- cli.c | 4 +++- mdp_client.c | 3 ++- rhizome_bundle.c | 9 +++++---- rhizome_database.c | 7 +++++-- rhizome_store.c | 5 +---- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cli.c b/cli.c index 29c5cfd4..c9500660 100644 --- a/cli.c +++ b/cli.c @@ -89,7 +89,9 @@ int cli_parse(const int argc, const char *const *args, const struct command_line int cli_invoke(const struct command_line_option *option, const int argc, const char *const *args, void *context) { - return option->function(argc, args, option, context); + IN(); + int ret=option->function(argc, args, option, context); + RETURN(ret); } int cli_arg(int argc, const char *const *argv, const struct command_line_option *o, char *argname, const char **dst, int (*validator)(const char *arg), char *defaultvalue) diff --git a/mdp_client.c b/mdp_client.c index c7a6e334..1db51350 100644 --- a/mdp_client.c +++ b/mdp_client.c @@ -142,6 +142,7 @@ int overlay_mdp_client_init() int overlay_mdp_client_done() { + IN(); if (mdp_client_socket!=-1) { /* Tell MDP server to release all our bindings */ overlay_mdp_frame mdp; @@ -154,7 +155,7 @@ int overlay_mdp_client_done() if (mdp_client_socket!=-1) close(mdp_client_socket); mdp_client_socket=-1; - return 0; + RETURN(0); } int overlay_mdp_client_poll(time_ms_t timeout_ms) diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 07e42596..a0530f50 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -627,6 +627,7 @@ int rhizome_manifest_dump(rhizome_manifest *m, const char *msg) int rhizome_manifest_finalise(rhizome_manifest *m, rhizome_manifest **mout) { + IN(); int ret=0; if (rhizome_manifest_check_duplicate(m, mout) == 2) { @@ -638,21 +639,21 @@ int rhizome_manifest_finalise(rhizome_manifest *m, rhizome_manifest **mout) /* Convert to final form for signing and writing to disk */ if (rhizome_manifest_pack_variables(m)) - return WHY("Could not convert manifest to wire format"); + RETURN(WHY("Could not convert manifest to wire format")); /* Sign it */ if (rhizome_manifest_selfsign(m)) - return WHY("Could not sign manifest"); + RETURN(WHY("Could not sign manifest")); /* mark manifest as finalised */ m->finalised=1; if (rhizome_add_manifest(m, 255 /* TTL */)) { rhizome_manifest_free(m); - return WHY("Manifest not added to Rhizome database"); + RETURN(WHY("Manifest not added to Rhizome database")); } } - return ret; + RETURN(ret); } int rhizome_fill_manifest(rhizome_manifest *m, const char *filepath, const sid_t *authorSid, rhizome_bk_t *bsk){ diff --git a/rhizome_database.c b/rhizome_database.c index 2692e5a4..5844372f 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -229,6 +229,7 @@ int rhizome_opendb() int rhizome_close_db() { + IN(); if (rhizome_db) { sqlite3_stmt *stmt = NULL; while ((stmt = sqlite3_next_stmt(rhizome_db, stmt))) { @@ -237,10 +238,10 @@ int rhizome_close_db() } int r = sqlite3_close(rhizome_db); if (r != SQLITE_OK) - return WHYF("Failed to close sqlite database, %s",sqlite3_errmsg(rhizome_db)); + RETURN(WHYF("Failed to close sqlite database, %s",sqlite3_errmsg(rhizome_db))); } rhizome_db=NULL; - return 0; + RETURN(0); } /* SQL query retry logic. @@ -585,6 +586,7 @@ long long rhizome_database_used_bytes() void rhizome_cleanup() { + IN(); // clean out unreferenced files // TODO keep updating inserttime for *very* long transfers? if (sqlite_exec_void("DELETE FROM FILES WHERE inserttime < %lld AND datavalid=0;", gettime_ms() - 300000)) { @@ -596,6 +598,7 @@ void rhizome_cleanup() if (sqlite_exec_void("DELETE FROM FILEBLOBS WHERE NOT EXISTS ( SELECT 1 FROM FILES WHERE FILES.id = FILEBLOBS.id );")) { WARNF("delete failed: %s", sqlite3_errmsg(rhizome_db)); } + OUT(); } int rhizome_make_space(int group_priority, long long bytes) diff --git a/rhizome_store.c b/rhizome_store.c index 7b170e48..5db42279 100644 --- a/rhizome_store.c +++ b/rhizome_store.c @@ -163,7 +163,6 @@ int rhizome_flush(struct rhizome_write *write){ DEBUGF("Written %lld of %lld", write->file_offset, write->file_length); write->data_size=0; return 0; - } /* Expects file to be at least file_length in size */ @@ -298,9 +297,7 @@ int rhizome_import_file(rhizome_manifest *m, const char *filepath) return -1; } - if (rhizome_finish_write(&write)) - return -1; - return 0; + return rhizome_finish_write(&write); } int rhizome_stat_file(rhizome_manifest *m, const char *filepath)