# HG changeset patch # User Sebastien Decugis # Date 1363098450 -3600 # Node ID 4158151cc694555ff2170e3fe10f3f635bcef7a2 # Parent 6e7437162f268bf17f0bf7a3d074f0e1f55070b9 Add counter for number of requests pending answers diff -r 6e7437162f26 -r 4158151cc694 libfdcore/fdcore-internal.h --- 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) */ diff -r 6e7437162f26 -r 4158151cc694 libfdcore/p_sr.c --- 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;