summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-08-15 17:49:14 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-08-15 17:49:14 +0200
commit3251c9f4e169f35d5f2410d777b848c49a91348a (patch)
tree8a0f308b7dca2c93e3542b796854add6e5f5311f
parent6ed77148e4a5b8bf9f3b4739d9e12c8af93b147e (diff)
downloadeficast-3251c9f4e169f35d5f2410d777b848c49a91348a.tar.gz
eficast-3251c9f4e169f35d5f2410d777b848c49a91348a.tar.bz2
eficast-3251c9f4e169f35d5f2410d777b848c49a91348a.zip
mcastleech: print dgrambuf stats at finalize_job state
-rw-r--r--mcastseed/src/dgrambuf.c19
-rw-r--r--mcastseed/src/dgrambuf.h2
-rw-r--r--mcastseed/src/mcastleech.c6
3 files changed, 26 insertions, 1 deletions
diff --git a/mcastseed/src/dgrambuf.c b/mcastseed/src/dgrambuf.c
index 061ae30..9feda89 100644
--- a/mcastseed/src/dgrambuf.c
+++ b/mcastseed/src/dgrambuf.c
@@ -29,7 +29,6 @@ struct dgrambuf_stats_t {
uint64_t dgrambuf_read_on_full;
uint64_t recvmmsg_calls, recv_dgrams, recv_byte;
uint64_t dgram_invalid, dgram_past, dgram_future, dgram_dup, dgram_end_marker;
- uint64_t qsort_calls;
uint64_t writev_calls, write_partial, write_byte;
};
@@ -406,6 +405,24 @@ ssize_t dgrambuf_write(dgrambuf_t dbuf, int fd, int *info) {
return nwrite;
}
+int dgrambuf_stats(dgrambuf_t dbuf, char **allocated_string) {
+ uint64_t dgram_pending = dgrambuf_get_used_count(dbuf);
+ uint64_t dgram_missing = dbuf->dgram_seq_last - (dbuf->dgram_seq_base - 1) - dgram_pending;
+
+ return asprintf(allocated_string,
+ "dgrambuf_read_on_full==%d "
+ "recvmmsg_calls==%d, recv_dgrams==%d, recv_byte==%d, "
+ "dgram_invalid==%d, dgram_past==%d, dgram_future==%d, dgram_dup==%d, dgram_end_marker==%d, "
+ "writev_calls==%d, write_partial==%d, write_byte==%d "
+ "dgram_pending==%d, dgram_missing==%d",
+ dbuf->stats.dgrambuf_read_on_full,
+ dbuf->stats.recvmmsg_calls, dbuf->stats.recv_dgrams, dbuf->stats.recv_byte,
+ dbuf->stats.dgram_invalid, dbuf->stats.dgram_past, dbuf->stats.dgram_future, dbuf->stats.dgram_dup, dbuf->stats.dgram_end_marker,
+ dbuf->stats.writev_calls, dbuf->stats.write_partial, dbuf->stats.write_byte,
+ dgram_pending, dgram_missing
+ );
+}
+
dgrambuf_t dgrambuf_new(size_t dgram_slots, size_t dgram_max_size, size_t dgram_header_size, size_t iovec_slots) {
const void **dgram_slot_seq_ptrs = NULL;
diff --git a/mcastseed/src/dgrambuf.h b/mcastseed/src/dgrambuf.h
index 52a6696..4d712c6 100644
--- a/mcastseed/src/dgrambuf.h
+++ b/mcastseed/src/dgrambuf.h
@@ -31,6 +31,8 @@ size_t dgrambuf_get_used_count(const dgrambuf_t);
int dgrambuf_have_data_ready_to_write(const dgrambuf_t);
int dgrambuf_have_received_everything(const dgrambuf_t);
+int dgrambuf_stats(dgrambuf_t dbuf, char **allocated_string);
+
/* Warning : dgrambuf_recvmmsg sets and restore SIGALRM handler if timeout != 0 */
ssize_t dgrambuf_recvmmsg(dgrambuf_t dbuf, int sockfd, int timeout, int *info);
ssize_t dgrambuf_write(dgrambuf_t dbuf, int fd, int *info);
diff --git a/mcastseed/src/mcastleech.c b/mcastseed/src/mcastleech.c
index a23e73a..76e1e79 100644
--- a/mcastseed/src/mcastleech.c
+++ b/mcastseed/src/mcastleech.c
@@ -246,6 +246,7 @@ int receive_data() {
int finalize_job() {
ssize_t nwrite;
int info_w, res;
+ char *stats;
/* Don't eat reources in a pooling fashion, blocking IO is fine when no more recv to do */
set_O_NONBLOCK(1, 0);
@@ -265,6 +266,11 @@ int finalize_job() {
return res;
}
+ res = dgrambuf_stats(dgrambuf, &stats);
+ if ( res != - 1 ) {
+ fprintf(stderr, "finalize_job(): dgrambuf_stats : %s\n",stats);
+ free(stats);
+ }
return 0;
}