Add html stats for http connection and mdp transfer counts

This commit is contained in:
Jeremy Lakeman 2013-09-24 14:23:40 +09:30
parent 5383b5e3be
commit b38b4720cc
5 changed files with 22 additions and 7 deletions

View File

@ -87,7 +87,7 @@ int rhizome_mdp_send_block(struct subscriber *dest, unsigned char *id, uint64_t
write_uint64(&reply.out.payload[1+16+8], offset);
int bytes_read = rhizome_read_cached(id, version, gettime_ms()+2000, offset, &reply.out.payload[1+16+8+8], blockLength);
int bytes_read = rhizome_read_cached(id, version, gettime_ms()+5000, offset, &reply.out.payload[1+16+8+8], blockLength);
if (bytes_read<=0)
break;

View File

@ -44,6 +44,7 @@ struct profile_total connection_stats;
unsigned short rhizome_http_server_port = 0;
static int rhizome_server_socket = -1;
static int request_count=0;
static time_ms_t rhizome_server_last_start_attempt = -1;
int (*rhizome_http_parse_func)(rhizome_http_request *)=NULL;
@ -283,7 +284,9 @@ void rhizome_server_poll(struct sched_ent *alarm)
if (request == NULL) {
WHYF_perror("calloc(%u, 1)", (int)sizeof(rhizome_http_request));
WHY("Cannot respond to request, out of memory");
close(sock);
} else {
request_count++;
request->uuid=rhizome_http_request_uuid_counter++;
if (peerip) request->requestor=*peerip;
else bzero(&request->requestor,sizeof(request->requestor));
@ -322,6 +325,7 @@ int rhizome_server_free_http_request(rhizome_http_request *r)
free(r->buffer);
rhizome_read_close(&r->read_state);
free(r);
request_count--;
return 0;
}
@ -402,6 +406,8 @@ static int rhizome_status_page(rhizome_http_request *r, const char *remainder, c
struct strbuf b;
strbuf_init(&b, buf, sizeof buf);
strbuf_puts(&b, "<html><head><meta http-equiv=\"refresh\" content=\"5\" ></head><body>");
strbuf_sprintf(&b, "%d HTTP requests<br>", request_count);
strbuf_sprintf(&b, "%d Bundles transferring via MDP<br>", rhizome_cache_count());
rhizome_fetch_status_html(&b);
strbuf_puts(&b, "</body></html>");
if (strbuf_overrun(&b))

View File

@ -338,12 +338,8 @@ int overlay_rhizome_saw_advertisements(int i, struct decode_context *context, st
}
/* Crude signature presence test */
for(i=m->manifest_all_bytes-1;i>0;i--)
if (!m->manifestdata[i]) {
/* A null in the middle says we have a signature */
break;
}
if (!i) {
if (m->manifest_bytes >= m->manifest_all_bytes){
// no signature was found when parsing?
/* ignore the announcement, but don't ignore other people
offering the same manifest */
if (config.debug.rhizome_ads)

View File

@ -959,6 +959,18 @@ int rhizome_cache_close()
return 0;
}
static int _rhizome_cache_count(struct cache_entry *entry)
{
if (!entry)
return 0;
return 1+_rhizome_cache_count(entry->_left)+_rhizome_cache_count(entry->_right);
}
int rhizome_cache_count()
{
return _rhizome_cache_count(root);
}
// read a block of data, caching meta data for reuse
int rhizome_read_cached(unsigned char *bundle_id, uint64_t version, time_ms_t timeout,
uint64_t fileOffset, unsigned char *buffer, int length)

View File

@ -598,6 +598,7 @@ int overlay_packet_init_header(int packet_version, int encapsulation,
int overlay_interface_args(const char *arg);
void overlay_rhizome_advertise(struct sched_ent *alarm);
void rhizome_sync_status_html(struct strbuf *b, struct subscriber *subscriber);
int rhizome_cache_count();
int overlay_add_local_identity(unsigned char *s);
extern int overlay_interface_count;