mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Encapsulate rhizome fetch logging
This commit is contained in:
parent
1681abd620
commit
28fc1da2d2
@ -149,17 +149,8 @@ int fd_showstats()
|
||||
stats = stats->_next;
|
||||
}
|
||||
|
||||
// Show periodic rhizome transfer information, but only
|
||||
// if there are some active rhizome transfers.
|
||||
if (rhizome_active_fetch_count()!=0)
|
||||
INFOF("Rhizome transfer progress: %"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64" (remaining %"PRIu64")",
|
||||
rhizome_active_fetch_bytes_received(0),
|
||||
rhizome_active_fetch_bytes_received(1),
|
||||
rhizome_active_fetch_bytes_received(2),
|
||||
rhizome_active_fetch_bytes_received(3),
|
||||
rhizome_active_fetch_bytes_received(4),
|
||||
rhizome_active_fetch_bytes_received(5),
|
||||
rhizome_fetch_queue_bytes());
|
||||
// Show periodic rhizome transfer information
|
||||
rhizome_fetch_log_short_status();
|
||||
|
||||
// Report any functions that take too much time
|
||||
if (!config.debug.timing)
|
||||
|
@ -898,7 +898,6 @@ enum rhizome_start_fetch_result {
|
||||
enum rhizome_start_fetch_result rhizome_fetch_request_manifest_by_prefix(const struct sockaddr_in *peerip, const sid_t *sidp, const unsigned char *prefix, size_t prefix_length);
|
||||
int rhizome_any_fetch_active();
|
||||
int rhizome_any_fetch_queued();
|
||||
uint64_t rhizome_fetch_queue_bytes();
|
||||
int rhizome_fetch_status_html(struct strbuf *b);
|
||||
int rhizome_fetch_has_queue_space(unsigned char log2_size);
|
||||
|
||||
|
@ -150,23 +150,14 @@ static const char * fetch_state(int state)
|
||||
}
|
||||
}
|
||||
|
||||
int rhizome_active_fetch_count()
|
||||
{
|
||||
int i,active=0;
|
||||
for(i=0;i<NQUEUES;i++)
|
||||
if (rhizome_fetch_queues[i].active.state!=RHIZOME_FETCH_FREE)
|
||||
active++;
|
||||
return active;
|
||||
}
|
||||
|
||||
uint64_t rhizome_active_fetch_bytes_received(int q)
|
||||
static uint64_t rhizome_active_fetch_bytes_received(int q)
|
||||
{
|
||||
if (q<0 || q>=NQUEUES) return -1;
|
||||
if (rhizome_fetch_queues[q].active.state==RHIZOME_FETCH_FREE) return -1;
|
||||
return rhizome_fetch_queues[q].active.write_state.file_offset;
|
||||
}
|
||||
|
||||
uint64_t rhizome_fetch_queue_bytes()
|
||||
static uint64_t rhizome_fetch_queue_bytes()
|
||||
{
|
||||
uint64_t bytes = 0;
|
||||
unsigned i;
|
||||
@ -186,6 +177,25 @@ uint64_t rhizome_fetch_queue_bytes()
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void rhizome_fetch_log_short_status()
|
||||
{
|
||||
int i,active=0;
|
||||
for(i=0;i<NQUEUES;i++)
|
||||
if (rhizome_fetch_queues[i].active.state!=RHIZOME_FETCH_FREE)
|
||||
active++;
|
||||
if (!active)
|
||||
return;
|
||||
|
||||
INFOF("Rhizome transfer progress: %"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64" (remaining %"PRIu64")",
|
||||
rhizome_active_fetch_bytes_received(0),
|
||||
rhizome_active_fetch_bytes_received(1),
|
||||
rhizome_active_fetch_bytes_received(2),
|
||||
rhizome_active_fetch_bytes_received(3),
|
||||
rhizome_active_fetch_bytes_received(4),
|
||||
rhizome_active_fetch_bytes_received(5),
|
||||
rhizome_fetch_queue_bytes());
|
||||
}
|
||||
|
||||
int rhizome_fetch_status_html(strbuf b)
|
||||
{
|
||||
unsigned i;
|
||||
|
3
serval.h
3
serval.h
@ -703,8 +703,7 @@ int slip_decode(struct slip_decode_state *state);
|
||||
int upper7_decode(struct slip_decode_state *state,unsigned char byte);
|
||||
uint32_t Crc32_ComputeBuf( uint32_t inCrc32, const void *buf,
|
||||
size_t bufLen );
|
||||
int rhizome_active_fetch_count();
|
||||
uint64_t rhizome_active_fetch_bytes_received(int q);
|
||||
void rhizome_fetch_log_short_status();
|
||||
extern int64_t bundles_available;
|
||||
extern char crash_handler_clue[1024];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user