Mercurial > hg > freeDiameter
changeset 1240:0420ccc4671a
Add a counter for the sent requests for which we did not wait for an answer. It might be relevant this value contributes to the load estimate of the remote peer, but it is not very reliable
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Thu, 10 Oct 2013 16:30:55 +0200 |
parents | b059b9e8ef83 |
children | 12c3e0c7fa0b |
files | libfdcore/fdcore-internal.h libfdcore/p_sr.c |
diffstat | 2 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libfdcore/fdcore-internal.h Thu Oct 10 16:19:23 2013 +0200 +++ b/libfdcore/fdcore-internal.h Thu Oct 10 16:30:55 2013 +0200 @@ -129,6 +129,8 @@ struct fd_list srs; /* requests ordered by hop-by-hop id */ struct fd_list exp; /* requests that have a timeout set, ordered by timeout */ long cnt; /* number of requests in the srs list */ + long cnt_lost; /* number of requests that have not been answered in time. + It is decremented when an unexpected answer is received, so this may not be accurate. */ 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 (expirecb called in separate forked threads) */
--- a/libfdcore/p_sr.c Thu Oct 10 16:19:23 2013 +0200 +++ b/libfdcore/p_sr.c Thu Oct 10 16:30:55 2013 +0200 @@ -163,6 +163,7 @@ /* Free the sentreq information */ fd_list_unlink(&first->chain); srlist->cnt--; + srlist->cnt_lost++; /* We are not waiting for this answer anymore, but the remote peer may still be processing it. */ fd_list_unlink(&first->expire); free(first); @@ -279,6 +280,9 @@ TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id (%x)", hbh); srl_dump("Current list of SR: ", &srlist->srs); *req = NULL; + if (srlist->cnt_lost > 0) { + srlist->cnt_lost--; /* This is probably an answer for a request we already timedout. */ + } /* else, probably a bug in the remote peer */ } else { /* Restore hop-by-hop id */ *((uint32_t *)sr->chain.o) = sr->prevhbh;