changeset 938:4158151cc694

Add counter for number of requests pending answers
author Sebastien Decugis <sdecugis@freediameter.net>
date Tue, 12 Mar 2013 15:27:30 +0100
parents 6e7437162f26
children 1bc052ef961f
files libfdcore/fdcore-internal.h libfdcore/p_sr.c
diffstat 2 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libfdcore/fdcore-internal.h	Sun Mar 10 04:24:36 2013 +0100
+++ b/libfdcore/fdcore-internal.h	Tue Mar 12 15:27:30 2013 +0100
@@ -125,6 +125,7 @@
 struct sr_list {
 	struct fd_list 	srs; /* requests ordered by hop-by-hop id */
 	struct fd_list  exp; /* requests that have a timeout set, ordered by timeout */
+	int             cnt; /* number of requests in the srs list */
 	pthread_mutex_t	mtx; /* mutex to protect these lists */
 	pthread_cond_t  cnd; /* cond var used by the thread that handles timeouts */
 	pthread_t       thr; /* the thread that handles timeouts (and calls the anscb) */
--- a/libfdcore/p_sr.c	Sun Mar 10 04:24:36 2013 +0100
+++ b/libfdcore/p_sr.c	Tue Mar 12 15:27:30 2013 +0100
@@ -225,6 +225,7 @@
 	/* Save in the list */
 	*req = NULL;
 	fd_list_insert_before(next, &sr->chain);
+	srlist->cnt++;
 	srl_dump("Saved new request, ", &srlist->srs);
 	
 	/* In case of request with a timeout, also store in the timeout list */
@@ -280,6 +281,7 @@
 		*((uint32_t *)sr->chain.o) = sr->prevhbh;
 		/* Unlink */
 		fd_list_unlink(&sr->chain);
+		srlist->cnt--;
 		fd_list_unlink(&sr->expire);
 		*req = sr->req;
 		free(sr);
@@ -299,6 +301,7 @@
 	while (!FD_IS_LIST_EMPTY(&srlist->srs)) {
 		struct sentreq * sr = (struct sentreq *)(srlist->srs.next);
 		fd_list_unlink(&sr->chain);
+		srlist->cnt--;
 		fd_list_unlink(&sr->expire);
 		if (fd_msg_is_routable(sr->req)) {
 			struct msg_hdr * hdr = NULL;
"Welcome to our mercurial repository"