# HG changeset patch # User Thomas Klausner # Date 1395663218 -3600 # Node ID 82280e745a897b20c156314ebec517918d1b6b6b # Parent 97caad40b665831c3495968716cd140cc3ce167b Remove whitespace at end of line. diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/redir_entries.c --- a/extensions/rt_redirect/redir_entries.c Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/redir_entries.c Mon Mar 24 13:13:38 2014 +0100 @@ -42,17 +42,17 @@ int redir_entry_init() { int i; - + TRACE_ENTRY(""); - + /* redirects_usages */ memset(&redirects_usages, 0, sizeof(redirects_usages)); - + for (i = 0; i <= H_U_MAX; i++) { CHECK_POSIX( pthread_rwlock_init( &redirects_usages[i].lock, NULL) ); fd_list_init( &redirects_usages[i].sentinel, &redirects_usages[i] ); } - + /* initialize the scores */ redirects_usages[ DONT_CACHE ].score = FD_SCORE_REDIR_ONCE; redirects_usages[ ALL_SESSION ].score = FD_SCORE_REDIR_SESSION; @@ -72,23 +72,23 @@ struct redir_entry * entry = NULL; os0_t s; size_t l; - + TRACE_ENTRY("%p %p %d %p %p %zd %p %zd", e, targets, rhu, qry, nh, nhlen, oh, ohlen) ASSERT(e && targets && (rhu <= H_U_MAX) && qry && nh && nhlen && oh && ohlen); - + CHECK_MALLOC( entry = malloc(sizeof(struct redir_entry)) ); memset(entry, 0, sizeof(struct redir_entry)); - + entry->eyec = REDIR_ENTRY_EYEC; - + CHECK_MALLOC( entry->from.s = os0dup(nh, nhlen) ); entry->from.l = nhlen; - + fd_list_init(&entry->target_peers_list, entry); fd_list_move_end(&entry->target_peers_list, targets); - + fd_list_init(&entry->exp_list, entry); - + entry->type = rhu; fd_list_init(&entry->redir_list, entry); /* finally initialize the data */ @@ -96,7 +96,7 @@ case DONT_CACHE: entry->data.message.msg = qry; break; - + case ALL_SESSION: { /* There is a good chance that the session is already cached in the message, so retrieve it */ @@ -113,7 +113,7 @@ entry->data.session.l = l; } break; - + case ALL_REALM: { /* Search the Destination-Realm of the message */ @@ -131,7 +131,7 @@ entry->data.realm.l = ahdr->avp_value->os.len; } break; - + case REALM_AND_APPLICATION: { /* Search the Destination-Realm of the message */ @@ -155,7 +155,7 @@ entry->data.realm_app.a = hdr->msg_appl; } break; - + case ALL_APPLICATION: { struct msg_hdr * hdr; @@ -163,12 +163,12 @@ entry->data.app.a = hdr->msg_appl; } break; - + case ALL_HOST: CHECK_MALLOC( entry->data.host.s = os0dup(oh, ohlen) ); entry->data.host.l = ohlen; break; - + case ALL_USER: { /* Search the User-Name of the message */ @@ -186,12 +186,12 @@ entry->data.user.l = ahdr->avp_value->os.len; } break; - + default: ASSERT(0); return EINVAL; } - + /* We're done */ *e = entry; return 0; @@ -202,7 +202,7 @@ static int compare_entries_ptr(union matchdata * d1, union matchdata * d2) { unsigned long v1 = (unsigned long) d1->message.msg; unsigned long v2 = (unsigned long) d2->message.msg; - if (v1 > v2) + if (v1 > v2) return 1; if (v1 < v2) return -1; @@ -210,9 +210,9 @@ } /* Compare two applications (REALM_AND_APPLICATION and ALL_APPLICATION) */ static int compare_entries_appl(union matchdata * d1, union matchdata * d2) { - if (d1->app.a > d2->app.a) + if (d1->app.a > d2->app.a) return 1; - if (d1->app.a < d2->app.a) + if (d1->app.a < d2->app.a) return -1; return 0; } @@ -237,22 +237,22 @@ int redir_entry_insert(struct redir_entry * e) { struct fd_list * li; - + TRACE_ENTRY("%p", e); CHECK_PARAMS(e && (e->eyec == REDIR_ENTRY_EYEC)); - + /* Write-Lock the line */ CHECK_POSIX( pthread_rwlock_wrlock( RWLOCK_REDIR(e) ) ); - + for (li = redirects_usages[e->type].sentinel.next; li != &redirects_usages[e->type].sentinel; li = li->next) { struct redir_entry * n = li->o; int cmp = redir_entry_cmp_key[e->type](&e->data, &n->data); if (cmp <= 0) break; } - + fd_list_insert_before(li, &e->redir_list); - + /* unLock the line */ CHECK_POSIX( pthread_rwlock_unlock( RWLOCK_REDIR(e) ) ); @@ -264,26 +264,26 @@ { TRACE_ENTRY("%p", e); CHECK_PARAMS(e && (e->eyec == REDIR_ENTRY_EYEC)); - + /* If the entry is linked, lock the rwlock also */ if (!FD_IS_LIST_EMPTY(&e->redir_list)) { CHECK_POSIX( pthread_rwlock_wrlock( RWLOCK_REDIR(e) ) ); fd_list_unlink(&e->redir_list); CHECK_POSIX( pthread_rwlock_unlock( RWLOCK_REDIR(e) ) ); } - + /* Now unlink from other list */ fd_list_unlink(&e->exp_list); - + /* Empty the targets list */ while (!FD_IS_LIST_EMPTY(&e->target_peers_list)) { struct redir_host * h = (struct redir_host *)e->target_peers_list.next->o; - + fd_list_unlink(&h->chain); free(h->id); free(h); } - + /* Now we can destroy the data safely */ switch (e->type) { case DONT_CACHE: @@ -311,9 +311,9 @@ ASSERT(0); return EINVAL; } - + free(e->from.s); - + free(e); return 0; } diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/redir_expiry.c --- a/extensions/rt_redirect/redir_expiry.c Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/redir_expiry.c Mon Mar 24 13:13:38 2014 +0100 @@ -40,23 +40,23 @@ /* Entries by their ascending expiration date, to accelerate the work of the expire thread */ static struct fd_list expire_list = FD_LIST_INITIALIZER(expire_list); -static pthread_cond_t exp_cnd = PTHREAD_COND_INITIALIZER; +static pthread_cond_t exp_cnd = PTHREAD_COND_INITIALIZER; pthread_mutex_t redir_exp_peer_lock = PTHREAD_MUTEX_INITIALIZER; /* The thread that handles expired entries cleanup. */ -void * redir_exp_thr_fct(void * arg) +void * redir_exp_thr_fct(void * arg) { fd_log_threadname ( "Redirects/expire" ); TRACE_ENTRY( "" ); CHECK_POSIX_DO( pthread_mutex_lock(&redir_exp_peer_lock), goto fatal_error ); pthread_cleanup_push( fd_cleanup_mutex, &redir_exp_peer_lock ); - + do { struct timespec now; struct redir_entry * first; -again: +again: /* Check if there are expiring entries available */ if (FD_IS_LIST_EMPTY(&expire_list)) { /* Just wait for a change or cancelation */ @@ -64,33 +64,33 @@ /* Restart the loop on wakeup */ goto again; } - + /* Get the pointer to the entry that expires first */ first = (struct redir_entry *)(expire_list.next->o); - + /* Get the current time */ CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), break ); /* If first session is not expired, we just wait until it happens */ if ( TS_IS_INFERIOR( &now, &first->timeout ) ) { - - CHECK_POSIX_DO2( pthread_cond_timedwait( &exp_cnd, &redir_exp_peer_lock, &first->timeout ), + + CHECK_POSIX_DO2( pthread_cond_timedwait( &exp_cnd, &redir_exp_peer_lock, &first->timeout ), ETIMEDOUT, /* ETIMEDOUT is a normal error, continue */, /* on other error, */ break ); - + /* on wakeup, loop */ goto again; } - + /* Now, the first entry in the list is expired; destroy it */ - + CHECK_FCT_DO( redir_entry_destroy( first ), break ); - + } while (1); - + pthread_cleanup_pop( 0 ); CHECK_POSIX_DO( pthread_mutex_unlock(&redir_exp_peer_lock), ); - + fatal_error: TRACE_DEBUG(INFO, "A system error occurred in redirect module! Expiry thread is terminating..."); ASSERT(0); @@ -103,33 +103,33 @@ struct fd_list * li; TRACE_ENTRY("%p %d", e, duration); CHECK_PARAMS(e && (e->eyec == REDIR_ENTRY_EYEC) && duration ); - + /* Unlink in case it was already set before */ fd_list_unlink(&e->exp_list); - + /* Get current time */ CHECK_SYS( clock_gettime(CLOCK_REALTIME, &e->timeout) ); - + /* Add the duration */ e->timeout.tv_sec += duration; - + /* now search the next element in the list */ for (li = expire_list.next; li != &expire_list; li = li->next) { struct redir_entry * n = li->o; - + if ( TS_IS_INFERIOR( &e->timeout, &n->timeout ) ) break; - + } - + /* Insert before this element */ fd_list_insert_before(li, &e->exp_list); - + /* Signal the expiry thread if needed */ if (e->exp_list.prev == &expire_list) { /* it is the first element */ CHECK_POSIX( pthread_cond_signal(&exp_cnd) ); } - + /* Done */ return 0; } diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/redir_fwd.c --- a/extensions/rt_redirect/redir_fwd.c Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/redir_fwd.c Mon Mar 24 13:13:38 2014 +0100 @@ -58,28 +58,28 @@ size_t nhlen; int nbrh = 0; struct redir_entry * entry; - + TRACE_ENTRY("%p %p", cbdata, msg); - + CHECK_PARAMS(msg && *msg); - + m = *msg; - + /* First get the header */ CHECK_FCT( fd_msg_hdr(m, &hdr) ); - + /* Check if we have an error */ ASSERT(!(hdr->msg_flags & CMD_FLAG_REQUEST)); if (!(hdr->msg_flags & CMD_FLAG_ERROR)) { /* This answer does not have the E flag, no need to process further */ return 0; } - + /* Now get the AVPs we are interested in */ CHECK_FCT( fd_msg_browse(m, MSG_BRW_FIRST_CHILD, &avp, NULL) ); while (avp) { struct avp_hdr * ahdr; - + CHECK_FCT( fd_msg_avp_hdr( avp, &ahdr ) ); if (! (ahdr->avp_flags & AVP_FLAG_VENDOR)) { switch (ahdr->avp_code) { @@ -89,19 +89,19 @@ ASSERT( ahdr->avp_value ); a_oh = ahdr->avp_value; break; - + case AC_RESULT_CODE: /* Parse this AVP */ CHECK_FCT( fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, NULL ) ); ASSERT( ahdr->avp_value ); a_rc = ahdr->avp_value; - + if (a_rc->u32 != ER_DIAMETER_REDIRECT_INDICATION) { /* It is not a REDIRECT error, we don't do anything */ goto out; } break; - + case AC_REDIRECT_HOST: { struct redir_host * h = NULL; @@ -111,20 +111,20 @@ uint16_t port = 0; int l4 = 0; char proto = 0; - + /* Parse this AVP */ CHECK_FCT( fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, NULL ) ); ASSERT( ahdr->avp_value ); - + nbrh++; - - CHECK_FCT_DO( fd_os_parse_DiameterURI(ahdr->avp_value->os.data, ahdr->avp_value->os.len, + + CHECK_FCT_DO( fd_os_parse_DiameterURI(ahdr->avp_value->os.data, ahdr->avp_value->os.len, &id, &len, &secure, &port, &l4, &proto), { TRACE_DEBUG(INFO, "Received an invalid Redirect-Host AVP value ('%.*s'), ignored", (int)ahdr->avp_value->os.len, ahdr->avp_value->os.data); break; } ); - + /* Now check if the transport & protocol are supported */ if (proto && (proto != 'd')) { TRACE_DEBUG(FULL, "Ignored unsupported non-Diameter Redirect-Host AVP (%.*s)", (int)ahdr->avp_value->os.len, ahdr->avp_value->os.data); @@ -136,16 +136,16 @@ free(id); break; } - + /* It looks OK, save this entry. */ - + CHECK_MALLOC( h = malloc(sizeof(struct redir_host)) ); memset(h, 0, sizeof(struct redir_host)); fd_list_init(&h->chain, h); h->id = id; h->len = len; /* later: secure, port */ - + /* The list is kept ordered by id so that it is faster to compare to candidates later */ for (li = task.rh.next; li != &task.rh; li = li->next) { struct redir_host * nhost = li->o; @@ -182,18 +182,18 @@ /* Go to next AVP */ CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); } - + /* Check we have received the necessary information */ if (!a_rc) { TRACE_DEBUG(FULL, "Invalid Diameter answer without a Result-Code AVP, Redirect module gave up"); goto out; } - + if (!a_oh) { TRACE_DEBUG(FULL, "Invalid Diameter answer without an Origin-Host AVP, Redirect module gave up"); goto out; } - + if (FD_IS_LIST_EMPTY(&task.rh)) { TRACE_DEBUG(FULL, "Diameter answer with a DIAMETER_REDIRECT_INDICATION Result-Code AVP but no valid/supported Redirect-Host AVP, Redirect module gave up"); goto out; @@ -203,14 +203,14 @@ TRACE_DEBUG(FULL, "Invalid Diameter Redirect answer with a Redirect-Host-Usage AVP but no Redirect-Max-Cache-Time, Redirect module gave up"); goto out; } - + /* It looks like we can process the Redirect indication */ - + /* Search for the peers we already know */ for (li = task.rh.next; li != &task.rh; li = li->next) { struct redir_host * h = li->o; struct peer_hdr * peer; - + CHECK_FCT( fd_peer_getbyid( h->id, h->len, 1, &peer ) ); if (peer) { known ++; @@ -220,28 +220,28 @@ } } } - + TRACE_DEBUG(FULL, "Redirect module: received %d Redirect-Hosts, %d are known peers, %d have an OPEN connection", nbrh, known, actives); - + /* in this version, we only redirect when there are known active peers. TODO: add new peers via fd_peer_add when no active peer is available */ - + if (!actives) { TRACE_DEBUG(INFO, "Unable to comply to Redirect indication: none of the peers included is in OPEN state"); goto out; } - + /* From this point, we will re-send the query to a different peer, so stop forwarding the answer here */ *msg = NULL; - + /* Get the query's routing data & add the new error */ CHECK_FCT( fd_msg_answ_getq(m, &q) ); CHECK_FCT( fd_msg_rt_get(q, &rtd) ); CHECK_FCT( fd_msg_source_get( m, &nh, &nhlen ) ); CHECK_FCT( fd_rtd_error_add(rtd, nh, nhlen, a_oh->os.data, a_oh->os.len, a_rc->u32, NULL, NULL) ); - + /* Create a redir_rule */ CHECK_FCT( redir_entry_new(&entry, &task.rh, task.rhu, q, nh, nhlen, a_oh->os.data, a_oh->os.len) ); - + CHECK_POSIX( pthread_mutex_lock(&redir_exp_peer_lock) ); /* Insert in the split list */ CHECK_FCT( redir_entry_insert(entry) ); @@ -252,12 +252,12 @@ /* Now we can get rid of the received answer and send again the query. */ CHECK_FCT( fd_msg_answ_detach(m) ); CHECK_FCT( fd_msg_free(m) ); - + /* Send it */ CHECK_FCT( fd_msg_send(&q, NULL, NULL) ); - + /* Done! */ - + out: while (!FD_IS_LIST_EMPTY(&task.rh)) { struct redir_host * h = task.rh.next->o; @@ -265,7 +265,7 @@ free(h->id); free(h); } - + return 0; } diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/redir_out.c --- a/extensions/rt_redirect/redir_out.c Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/redir_out.c Mon Mar 24 13:13:38 2014 +0100 @@ -40,17 +40,17 @@ static int get_data_to_match(enum redir_h_u type, struct msg *msg, union matchdata * data, int * nodata) { TRACE_ENTRY("%d %p %p %p", type, msg, data, nodata); - + /* Initialize the data area */ memset(data, 0, sizeof(union matchdata)); *nodata = 0; - + /* Now, find the appropriate information, depending on type */ switch (type) { case DONT_CACHE: data->message.msg = msg; break; - + case ALL_SESSION: { /* Get the sid from the message */ @@ -64,7 +64,7 @@ } } break; - + case ALL_REALM: { /* Search the Destination-Realm in the message */ @@ -81,7 +81,7 @@ } } break; - + case REALM_AND_APPLICATION: { /* Search the Destination-Realm of the message */ @@ -95,7 +95,7 @@ CHECK_FCT( fd_msg_avp_hdr( dr, &ahdr ) ); data->realm_app.s = ahdr->avp_value->os.data; data->realm_app.l = ahdr->avp_value->os.len; - + /* and then the application */ { struct msg_hdr * hdr; @@ -106,7 +106,7 @@ } } break; - + case ALL_APPLICATION: { /* Retrieve the application from the message */ @@ -115,11 +115,11 @@ data->app.a = hdr->msg_appl; } break; - + case ALL_HOST: /* This is more complex, we need to match with all candidates in each rule, it'll be done later */ break; - + case ALL_USER: { /* Search the User-Name of the message */ @@ -136,7 +136,7 @@ } } break; - + default: ASSERT(0); return EINVAL; @@ -152,22 +152,22 @@ struct fd_list * lic, *lirh; struct rtd_candidate * c_oh = NULL; int cmp; - + TRACE_ENTRY("%p %p %p", e, msg, candidates); ASSERT( e && msg && candidates ); - + if (FD_IS_LIST_EMPTY(candidates)) { TRACE_DEBUG(ANNOYING, "Skip Redirect rule since candidates list is empty"); return 0; } - + /* Now search common peers between e->target_peers_list and candidates */ TRACE_DEBUG(ANNOYING, "Message %p matches a Redirect rule (t:%d, @%p), processing candidates list", msg, e->type, e); - + /* First, decrease the score of the host that we received the previous Redirect from, in case it is in the list */ for (lic = candidates->next; lic != candidates; lic = lic->next) { struct rtd_candidate * cand = (struct rtd_candidate *) lic; - + /* Special case: ALL_HOST rules: we decrease the score of the Origin-Host if present */ if (e->type == ALL_HOST) { cmp = fd_os_almostcasesrch(cand->diamid, cand->diamidlen, e->data.host.s, e->data.host.l, NULL); @@ -178,32 +178,32 @@ continue; } } - + cmp = fd_os_cmp(cand->diamid, cand->diamidlen, e->from.s, e->from.l); if (!cmp) { TRACE_DEBUG(FULL, "Redirect msg %p: peer '%.*s' += %d (previous Redirect received from this peer)", msg, (int)cand->diamidlen, cand->diamid, FD_SCORE_SENT_REDIRECT); cand->score += FD_SCORE_SENT_REDIRECT; } - + } - + if ((e->type == ALL_HOST) && (c_oh == NULL)) { /* The rule does not apply, we're done */ return 0; } - + /* for each candidate, if it is found in the target_peers list, we add the rule's score to this candidate */ for (lic = candidates->next; lic != candidates; lic = lic->next) { /* the candidates list is not guaranteed to be ordered at this time, so we cannot avoid the two imbricated loops */ struct rtd_candidate * cand = (struct rtd_candidate *) lic; - + /* Is this candidate in the "Redirect-Host" list ? We must search caseinsentive here. */ for (lirh = e->target_peers_list.next; lirh != &e->target_peers_list; lirh = lirh->next) { struct redir_host * host = lirh->o; int cont; - + cmp = fd_os_almostcasesrch( cand->diamid, cand->diamidlen, host->id, host->len, &cont ); - + if (cmp == 0) { TRACE_DEBUG(FULL, "Redirect msg %p: peer '%.*s' += %d (rule t:%d @%p)", msg, (int)cand->diamidlen, cand->diamid, redirects_usages[e->type].score, e->type, e); cand->score += redirects_usages[e->type].score; @@ -213,7 +213,7 @@ break; } } - + return 0; } @@ -223,9 +223,9 @@ { int i, ret = 0; struct msg * msg = *pmsg; - + TRACE_ENTRY("%p %p %p", cbdata, msg, candidates); - + for (i = 0; i <= H_U_MAX; i++) { /* Lock the line. We write lock in case of DONT_CACHE so we can directly unlink the entry. read in other cases is sufficient */ if (i == DONT_CACHE) { @@ -233,21 +233,21 @@ } else { CHECK_POSIX( pthread_rwlock_rdlock( &redirects_usages[i].lock ) ); } - + if (!FD_IS_LIST_EMPTY(&redirects_usages[i].sentinel)) { union matchdata data; int nodata; /* The message does not allow to apply this rule, skip */ - + /* Retrieve the data that may match in the message */ CHECK_FCT_DO( ret = get_data_to_match(i, msg, &data, &nodata), goto out ); - + /* If this message may match some of our rules */ if (!nodata) { struct fd_list * li; /* Attempt each rule we have stored */ for (li = redirects_usages[i].sentinel.next; li != &redirects_usages[i].sentinel; li = li->next) { struct redir_entry * e = li->o; - + /* Does it match ? */ if (i != ALL_HOST) { /* this one is an exception, we handle it separately */ int cmp = redir_entry_cmp_key[i](&data, &e->data); @@ -256,27 +256,27 @@ if (cmp < 0) break; } - + /* This rule matches (or we are in ALL_HOST), apply */ CHECK_FCT_DO( ret = apply_rule(e, msg, candidates), goto out ); - + /* If this was a DONT_CACHE rule, we unlink it, so that it will not be used again */ if (i == DONT_CACHE) { li=li->prev; fd_list_unlink( li->next ); - /* We cannot delete here without taking the mutex, which would mean we have first to release the lock... + /* We cannot delete here without taking the mutex, which would mean we have first to release the lock... just let expiry garbage collet the rule */ } } } - + } -out: +out: CHECK_POSIX( pthread_rwlock_unlock( &redirects_usages[i].lock ) ); if (ret) return ret; } - + return 0; } diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/rt_redir.c --- a/extensions/rt_redirect/rt_redir.c Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/rt_redir.c Mon Mar 24 13:13:38 2014 +0100 @@ -46,17 +46,17 @@ static int redir_entry(char * conffile) { TRACE_ENTRY(""); - + /* Dictionary objects */ CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &redir_dict_dr, ENOENT) ); CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &redir_dict_un, ENOENT) ); /* Initialize the entries array */ CHECK_FCT( redir_entry_init() ); - + /* Start the expire thread */ CHECK_POSIX( pthread_create( &exp_thr, NULL, redir_exp_thr_fct, NULL ) ); - + /* Register the callback that receives the answers and processes when it contains a Redirect indication. */ CHECK_FCT( fd_rt_fwd_register ( redir_fwd_cb, NULL, RT_FWD_ANS, &fwd_hdl ) ); @@ -72,7 +72,7 @@ void fd_ext_fini(void) { int i; - + /* Unregister the callbacks */ if (fwd_hdl) { CHECK_FCT_DO( fd_rt_fwd_unregister(fwd_hdl, NULL), ); @@ -80,10 +80,10 @@ if (out_hdl) { CHECK_FCT_DO( fd_rt_out_unregister(out_hdl, NULL), ); } - + /* Stop the expiry thread */ CHECK_FCT_DO( fd_thr_term(&exp_thr), ); - + /* Empty all entries */ CHECK_POSIX_DO( pthread_mutex_lock(&redir_exp_peer_lock), ); for (i = 0; i <= H_U_MAX; i++) { @@ -97,6 +97,6 @@ CHECK_POSIX_DO( pthread_rwlock_destroy( &redirects_usages[i].lock), ); } CHECK_POSIX_DO( pthread_mutex_unlock(&redir_exp_peer_lock), ); - + return; } diff -r 97caad40b665 -r 82280e745a89 extensions/rt_redirect/rt_redir.h --- a/extensions/rt_redirect/rt_redir.h Tue Feb 11 14:47:02 2014 +0100 +++ b/extensions/rt_redirect/rt_redir.h Mon Mar 24 13:13:38 2014 +0100 @@ -38,7 +38,7 @@ /* There are 2 locks in this module. The priority is established as follow to avoid deadlocks: exp_peer mutex > usages rwlock. -(e.g., the rwlock can be taken while holding the mutex, but not the other way) +(e.g., the rwlock can be taken while holding the mutex, but not the other way) */ /* The types of redirects (from Redirect-Host-Usage AVP value) */ @@ -58,14 +58,14 @@ /* Expiration time set for DONT_CACHE tasks, so that the entry is found when the code is called back */ #define DEFAULT_EXPIRE_TIME 10 /* seconds */ - + /* Structure to store a parsed Redirect-Host */ struct redir_host { - struct fd_list chain; - + struct fd_list chain; + DiamId_t id; /* malloc'd */ size_t len; - /* We don't use the following yet because we don't support dynamic new connections + /* We don't use the following yet because we don't support dynamic new connections int secure; uint16_t port; int l4; @@ -116,12 +116,12 @@ size_t l; } user; }; - + /* Structure to store a Redirect indication */ struct redir_entry { uint32_t eyec; /* must be REDIR_ENTRY_EYEC, used for debug only */ - + struct { os0_t s; /* alloc'd, must be freed */ size_t l; @@ -131,7 +131,7 @@ struct timespec timeout; /* When does this entry expires? */ struct fd_list exp_list; /* chain in the expire_list list, ordered by expiration date, protected by exp_peer_lock */ - + enum redir_h_u type; /* Type of this entry */ struct fd_list redir_list; /* link in redirects_usages lists. Lists are ordered by the data value. Protected by rw locks */ union matchdata data; /* The strings are duplicated & must be freed in this structure */