# HG changeset patch # User Thomas Klausner # Date 1363099673 -3600 # Node ID 652713ce3596642509e078e69f279cafb409bcc9 # Parent bbc08d58325a23fb6d56410c2b63d43107232bf3# Parent 9b00b868e308d5d5bcfcd8a7881de74c779f809e merge main diff -r bbc08d58325a -r 652713ce3596 include/freeDiameter/libfdcore.h --- a/include/freeDiameter/libfdcore.h Sun Mar 10 09:57:57 2013 +0100 +++ b/include/freeDiameter/libfdcore.h Tue Mar 12 15:47:53 2013 +0100 @@ -384,6 +384,23 @@ */ int fd_peer_get_state(struct peer_hdr *peer); +/* + * FUNCTION: fd_peer_get_load_pending + * + * PARAMETERS: + * peer : The peer which load to read + * + * DESCRIPTION: + * Returns the current number of requests sent to this peer + * that have not been answered yet. This is an empirical indication + * of the workload of this peer. + * + * RETURN VALUE: + * 0 : The load parameter has been updated. (it should have a positive value always) + * !0 : An error occurred + */ +int fd_peer_get_load_pending(struct peer_hdr *peer, int * load); + /* * FUNCTION: fd_peer_validate_register * diff -r bbc08d58325a -r 652713ce3596 libfdcore/fdcore-internal.h --- a/libfdcore/fdcore-internal.h Sun Mar 10 09:57:57 2013 +0100 +++ b/libfdcore/fdcore-internal.h Tue Mar 12 15:47:53 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 bbc08d58325a -r 652713ce3596 libfdcore/fdd.l --- a/libfdcore/fdd.l Sun Mar 10 09:57:57 2013 +0100 +++ b/libfdcore/fdd.l Tue Mar 12 15:47:53 2013 +0100 @@ -51,7 +51,7 @@ #define YY_USER_ACTION { \ yylloc->first_column = yylloc->last_column + 1; \ yylloc->last_column = yylloc->first_column + yyleng - 1; \ - TRACE_DEBUG_ERROR( \ + fd_log_debug( \ "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \ yylloc->first_line, yylloc->first_column, \ yylloc->last_line, yylloc->last_column, \ diff -r bbc08d58325a -r 652713ce3596 libfdcore/p_sr.c --- a/libfdcore/p_sr.c Sun Mar 10 09:57:57 2013 +0100 +++ b/libfdcore/p_sr.c Tue Mar 12 15:47:53 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; diff -r bbc08d58325a -r 652713ce3596 libfdcore/peers.c --- a/libfdcore/peers.c Sun Mar 10 09:57:57 2013 +0100 +++ b/libfdcore/peers.c Tue Mar 12 15:47:53 2013 +0100 @@ -256,6 +256,21 @@ return; } +/* Return the value of srlist->cnt */ +int fd_peer_get_load_pending(struct peer_hdr *peer, int * load) +{ + struct fd_peer * p = (struct fd_peer *)peer; + TRACE_ENTRY("%p %p", peer, load); + CHECK_PARAMS(CHECK_PEER(peer) && load); + + CHECK_POSIX( pthread_mutex_lock(&p->p_sr.mtx) ); + *load = p->p_sr.cnt; + CHECK_POSIX( pthread_mutex_unlock(&p->p_sr.mtx) ); + + return 0; +} + + /* Destroy a structure once cleanups have been performed (fd_psm_abord, ...) */ int fd_peer_free(struct fd_peer ** ptr) { @@ -394,7 +409,7 @@ return; } - fd_log_debug("> %s\t%s", STATE_STR(fd_peer_getstate(peer)), peer->p_hdr.info.pi_diamid); + fd_log_debug("> %s\t%s\t[%dsr]", STATE_STR(fd_peer_getstate(peer)), peer->p_hdr.info.pi_diamid, peer->p_sr.cnt); if (details > INFO) { fd_log_debug("\t(rlm:%s)", peer->p_hdr.info.runtime.pir_realm ?: ""); if (peer->p_hdr.info.runtime.pir_prodname)