# HG changeset patch # User Sebastien Decugis # Date 1381415455 -7200 # Node ID 0420ccc4671ab7f1d371145d99f1931b01fe7cbb # Parent b059b9e8ef83c52ef0a09ad20ec4dfc5b346cbc9 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 diff -r b059b9e8ef83 -r 0420ccc4671a libfdcore/fdcore-internal.h --- 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) */ diff -r b059b9e8ef83 -r 0420ccc4671a libfdcore/p_sr.c --- 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;