mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 14:07:53 +00:00
Add more profiling instrumentation
This commit is contained in:
parent
78a8aaca16
commit
495de9e0ec
@ -211,6 +211,10 @@ int parseCommandLine(int argc, const char *const *args)
|
|||||||
int i;
|
int i;
|
||||||
int ambiguous=0;
|
int ambiguous=0;
|
||||||
int cli_call=-1;
|
int cli_call=-1;
|
||||||
|
|
||||||
|
fd_clearstats();
|
||||||
|
|
||||||
|
IN();
|
||||||
for(i=0;command_line_options[i].function;i++)
|
for(i=0;command_line_options[i].function;i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
@ -277,6 +281,10 @@ int parseCommandLine(int argc, const char *const *args)
|
|||||||
int result=command_line_options[cli_call].function(argc, args, &command_line_options[cli_call]);
|
int result=command_line_options[cli_call].function(argc, args, &command_line_options[cli_call]);
|
||||||
/* clean up after ourselves */
|
/* clean up after ourselves */
|
||||||
overlay_mdp_client_done();
|
overlay_mdp_client_done();
|
||||||
|
OUT();
|
||||||
|
//TODO debug flag for method profiling
|
||||||
|
if (1)
|
||||||
|
fd_showstats();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
keyring.c
14
keyring.c
@ -739,7 +739,8 @@ int keyring_decrypt_pkr(keyring_file *k,keyring_context *c,
|
|||||||
We might find more than one. */
|
We might find more than one. */
|
||||||
int keyring_enter_pin(keyring_file *k, const char *pin)
|
int keyring_enter_pin(keyring_file *k, const char *pin)
|
||||||
{
|
{
|
||||||
if (!k) return -1;
|
IN();
|
||||||
|
if (!k) RETURN(-1);
|
||||||
if (!pin) pin="";
|
if (!pin) pin="";
|
||||||
|
|
||||||
int slot;
|
int slot;
|
||||||
@ -777,7 +778,7 @@ int keyring_enter_pin(keyring_file *k, const char *pin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Tell the caller how many identities we found */
|
/* Tell the caller how many identities we found */
|
||||||
return identitiesFound;
|
RETURN(identitiesFound);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,15 +1386,16 @@ int keyring_enter_pins(keyring_file *k, const char *pinlist)
|
|||||||
keyring_file *keyring_open_with_pins(const char *pinlist)
|
keyring_file *keyring_open_with_pins(const char *pinlist)
|
||||||
{
|
{
|
||||||
keyring_file *k = NULL;
|
keyring_file *k = NULL;
|
||||||
|
IN();
|
||||||
if (create_serval_instance_dir() == -1)
|
if (create_serval_instance_dir() == -1)
|
||||||
return NULL;
|
RETURN(NULL);
|
||||||
char keyringFile[1024];
|
char keyringFile[1024];
|
||||||
if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring"))
|
if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring"))
|
||||||
return NULL;
|
RETURN(NULL);
|
||||||
if ((k = keyring_open(keyringFile)) == NULL)
|
if ((k = keyring_open(keyringFile)) == NULL)
|
||||||
return NULL;
|
RETURN(NULL);
|
||||||
keyring_enter_pins(k,pinlist);
|
keyring_enter_pins(k,pinlist);
|
||||||
return k;
|
RETURN(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no identities, create an initial identity with a phone number.
|
/* If no identities, create an initial identity with a phone number.
|
||||||
|
@ -1253,6 +1253,8 @@ int overlay_mdp_client_done()
|
|||||||
int overlay_mdp_client_poll(long long timeout_ms)
|
int overlay_mdp_client_poll(long long timeout_ms)
|
||||||
{
|
{
|
||||||
fd_set r;
|
fd_set r;
|
||||||
|
int ret;
|
||||||
|
IN();
|
||||||
FD_ZERO(&r);
|
FD_ZERO(&r);
|
||||||
FD_SET(mdp_client_socket,&r);
|
FD_SET(mdp_client_socket,&r);
|
||||||
if (timeout_ms<0) timeout_ms=0;
|
if (timeout_ms<0) timeout_ms=0;
|
||||||
@ -1262,10 +1264,11 @@ int overlay_mdp_client_poll(long long timeout_ms)
|
|||||||
if (timeout_ms>=0) {
|
if (timeout_ms>=0) {
|
||||||
tv.tv_sec=timeout_ms/1000;
|
tv.tv_sec=timeout_ms/1000;
|
||||||
tv.tv_usec=(timeout_ms%1000)*1000;
|
tv.tv_usec=(timeout_ms%1000)*1000;
|
||||||
return select(mdp_client_socket+1,&r,NULL,&r,&tv);
|
ret=select(mdp_client_socket+1,&r,NULL,&r,&tv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return select(mdp_client_socket+1,&r,NULL,&r,NULL);
|
ret=select(mdp_client_socket+1,&r,NULL,&r,NULL);
|
||||||
|
RETURN(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int overlay_mdp_recv(overlay_mdp_frame *mdp,int *ttl)
|
int overlay_mdp_recv(overlay_mdp_frame *mdp,int *ttl)
|
||||||
|
@ -84,8 +84,9 @@ int rhizome_manifest_verify(rhizome_manifest *m)
|
|||||||
|
|
||||||
int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bufferP)
|
int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bufferP)
|
||||||
{
|
{
|
||||||
if (bufferP>MAX_MANIFEST_BYTES) return WHY("Buffer too big");
|
IN();
|
||||||
if (!m) return WHY("Null manifest");
|
if (bufferP>MAX_MANIFEST_BYTES) RETURN(WHY("Buffer too big"));
|
||||||
|
if (!m) RETURN(WHY("Null manifest"));
|
||||||
|
|
||||||
if (bufferP) {
|
if (bufferP) {
|
||||||
m->manifest_bytes=bufferP;
|
m->manifest_bytes=bufferP;
|
||||||
@ -93,7 +94,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
|
|||||||
} else {
|
} else {
|
||||||
FILE *f = fopen(filename, "r");
|
FILE *f = fopen(filename, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return WHYF("Could not open manifest file %s for reading.", filename);
|
RETURN(WHYF("Could not open manifest file %s for reading.", filename));
|
||||||
m->manifest_bytes = fread(m->manifestdata, 1, MAX_MANIFEST_BYTES, f);
|
m->manifest_bytes = fread(m->manifestdata, 1, MAX_MANIFEST_BYTES, f);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (m->manifest_bytes == -1)
|
if (m->manifest_bytes == -1)
|
||||||
@ -101,7 +102,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
|
|||||||
if (fclose(f) == EOF)
|
if (fclose(f) == EOF)
|
||||||
ret = WHY_perror("fclose");
|
ret = WHY_perror("fclose");
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return -1;
|
RETURN(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
m->manifest_all_bytes=m->manifest_bytes;
|
m->manifest_all_bytes=m->manifest_bytes;
|
||||||
@ -175,7 +176,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
|
|||||||
|
|
||||||
m->manifest_bytes=end_of_text;
|
m->manifest_bytes=end_of_text;
|
||||||
|
|
||||||
return 0;
|
RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rhizome_hash_file(rhizome_manifest *m,const char *filename,char *hash_out)
|
int rhizome_hash_file(rhizome_manifest *m,const char *filename,char *hash_out)
|
||||||
|
@ -658,6 +658,7 @@ int rhizome_finish_sqlstatement(sqlite3_stmt *statement)
|
|||||||
|
|
||||||
int rhizome_list_manifests(const char *service, const char *sender_sid, const char *recipient_sid, int limit, int offset)
|
int rhizome_list_manifests(const char *service, const char *sender_sid, const char *recipient_sid, int limit, int offset)
|
||||||
{
|
{
|
||||||
|
IN();
|
||||||
strbuf b = strbuf_alloca(1024);
|
strbuf b = strbuf_alloca(1024);
|
||||||
strbuf_sprintf(b, "SELECT id, manifest, version, inserttime FROM manifests ORDER BY inserttime DESC");
|
strbuf_sprintf(b, "SELECT id, manifest, version, inserttime FROM manifests ORDER BY inserttime DESC");
|
||||||
if (limit)
|
if (limit)
|
||||||
@ -665,7 +666,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
|
|||||||
if (offset)
|
if (offset)
|
||||||
strbuf_sprintf(b, " OFFSET %u", offset);
|
strbuf_sprintf(b, " OFFSET %u", offset);
|
||||||
if (strbuf_overrun(b))
|
if (strbuf_overrun(b))
|
||||||
return WHYF("SQL command too long: ", strbuf_str(b));
|
RETURN(WHYF("SQL command too long: ", strbuf_str(b)));
|
||||||
sqlite3_stmt *statement;
|
sqlite3_stmt *statement;
|
||||||
const char *cmdtail;
|
const char *cmdtail;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -751,7 +752,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3_finalize(statement);
|
sqlite3_finalize(statement);
|
||||||
return ret;
|
RETURN(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following function just stores the file (or silently returns if it already exists).
|
/* The following function just stores the file (or silently returns if it already exists).
|
||||||
|
Loading…
Reference in New Issue
Block a user