Minor improvements to command line time measurements

This commit is contained in:
Jeremy Lakeman 2013-01-03 14:16:33 +10:30
parent 2e761c17fa
commit e26522bdc6
5 changed files with 16 additions and 12 deletions

4
cli.c
View File

@ -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)

View File

@ -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)

View File

@ -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){

View File

@ -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)

View File

@ -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)