mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 14:07:53 +00:00
Minor improvements to command line time measurements
This commit is contained in:
parent
2e761c17fa
commit
e26522bdc6
4
cli.c
4
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)
|
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)
|
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)
|
||||||
|
@ -142,6 +142,7 @@ int overlay_mdp_client_init()
|
|||||||
|
|
||||||
int overlay_mdp_client_done()
|
int overlay_mdp_client_done()
|
||||||
{
|
{
|
||||||
|
IN();
|
||||||
if (mdp_client_socket!=-1) {
|
if (mdp_client_socket!=-1) {
|
||||||
/* Tell MDP server to release all our bindings */
|
/* Tell MDP server to release all our bindings */
|
||||||
overlay_mdp_frame mdp;
|
overlay_mdp_frame mdp;
|
||||||
@ -154,7 +155,7 @@ int overlay_mdp_client_done()
|
|||||||
if (mdp_client_socket!=-1)
|
if (mdp_client_socket!=-1)
|
||||||
close(mdp_client_socket);
|
close(mdp_client_socket);
|
||||||
mdp_client_socket=-1;
|
mdp_client_socket=-1;
|
||||||
return 0;
|
RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int overlay_mdp_client_poll(time_ms_t timeout_ms)
|
int overlay_mdp_client_poll(time_ms_t timeout_ms)
|
||||||
|
@ -627,6 +627,7 @@ int rhizome_manifest_dump(rhizome_manifest *m, const char *msg)
|
|||||||
|
|
||||||
int rhizome_manifest_finalise(rhizome_manifest *m, rhizome_manifest **mout)
|
int rhizome_manifest_finalise(rhizome_manifest *m, rhizome_manifest **mout)
|
||||||
{
|
{
|
||||||
|
IN();
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
if (rhizome_manifest_check_duplicate(m, mout) == 2) {
|
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 */
|
/* Convert to final form for signing and writing to disk */
|
||||||
if (rhizome_manifest_pack_variables(m))
|
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 */
|
/* Sign it */
|
||||||
if (rhizome_manifest_selfsign(m))
|
if (rhizome_manifest_selfsign(m))
|
||||||
return WHY("Could not sign manifest");
|
RETURN(WHY("Could not sign manifest"));
|
||||||
|
|
||||||
/* mark manifest as finalised */
|
/* mark manifest as finalised */
|
||||||
m->finalised=1;
|
m->finalised=1;
|
||||||
if (rhizome_add_manifest(m, 255 /* TTL */)) {
|
if (rhizome_add_manifest(m, 255 /* TTL */)) {
|
||||||
rhizome_manifest_free(m);
|
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){
|
int rhizome_fill_manifest(rhizome_manifest *m, const char *filepath, const sid_t *authorSid, rhizome_bk_t *bsk){
|
||||||
|
@ -229,6 +229,7 @@ int rhizome_opendb()
|
|||||||
|
|
||||||
int rhizome_close_db()
|
int rhizome_close_db()
|
||||||
{
|
{
|
||||||
|
IN();
|
||||||
if (rhizome_db) {
|
if (rhizome_db) {
|
||||||
sqlite3_stmt *stmt = NULL;
|
sqlite3_stmt *stmt = NULL;
|
||||||
while ((stmt = sqlite3_next_stmt(rhizome_db, stmt))) {
|
while ((stmt = sqlite3_next_stmt(rhizome_db, stmt))) {
|
||||||
@ -237,10 +238,10 @@ int rhizome_close_db()
|
|||||||
}
|
}
|
||||||
int r = sqlite3_close(rhizome_db);
|
int r = sqlite3_close(rhizome_db);
|
||||||
if (r != SQLITE_OK)
|
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;
|
rhizome_db=NULL;
|
||||||
return 0;
|
RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL query retry logic.
|
/* SQL query retry logic.
|
||||||
@ -585,6 +586,7 @@ long long rhizome_database_used_bytes()
|
|||||||
|
|
||||||
void rhizome_cleanup()
|
void rhizome_cleanup()
|
||||||
{
|
{
|
||||||
|
IN();
|
||||||
// clean out unreferenced files
|
// clean out unreferenced files
|
||||||
// TODO keep updating inserttime for *very* long transfers?
|
// TODO keep updating inserttime for *very* long transfers?
|
||||||
if (sqlite_exec_void("DELETE FROM FILES WHERE inserttime < %lld AND datavalid=0;", gettime_ms() - 300000)) {
|
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 );")) {
|
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));
|
WARNF("delete failed: %s", sqlite3_errmsg(rhizome_db));
|
||||||
}
|
}
|
||||||
|
OUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
int rhizome_make_space(int group_priority, long long bytes)
|
int rhizome_make_space(int group_priority, long long bytes)
|
||||||
|
@ -163,7 +163,6 @@ int rhizome_flush(struct rhizome_write *write){
|
|||||||
DEBUGF("Written %lld of %lld", write->file_offset, write->file_length);
|
DEBUGF("Written %lld of %lld", write->file_offset, write->file_length);
|
||||||
write->data_size=0;
|
write->data_size=0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expects file to be at least file_length in size */
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rhizome_finish_write(&write))
|
return rhizome_finish_write(&write);
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rhizome_stat_file(rhizome_manifest *m, const char *filepath)
|
int rhizome_stat_file(rhizome_manifest *m, const char *filepath)
|
||||||
|
Loading…
Reference in New Issue
Block a user