Navigation



Ignore:
Timestamp:
Mar 24, 2014, 9:13:38 PM (10 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Remove whitespace at end of line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rt_redirect/redir_out.c

    r1216 r1259  
    4141{
    4242        TRACE_ENTRY("%d %p %p %p", type, msg, data, nodata);
    43        
     43
    4444        /* Initialize the data area */
    4545        memset(data, 0, sizeof(union matchdata));
    4646        *nodata = 0;
    47        
     47
    4848        /* Now, find the appropriate information, depending on type */
    4949        switch (type) {
     
    5151                        data->message.msg = msg;
    5252                        break;
    53                        
     53
    5454                case ALL_SESSION:
    5555                        {
     
    6565                        }
    6666                        break;
    67                
     67
    6868                case ALL_REALM:
    6969                        {
     
    8282                        }
    8383                        break;
    84                                
     84
    8585                case REALM_AND_APPLICATION:
    8686                        {
     
    9696                                        data->realm_app.s = ahdr->avp_value->os.data;
    9797                                        data->realm_app.l = ahdr->avp_value->os.len;
    98                                        
     98
    9999                                        /* and then the application */
    100100                                        {
     
    107107                        }
    108108                        break;
    109                                
     109
    110110                case ALL_APPLICATION:
    111111                        {
     
    116116                        }
    117117                        break;
    118                        
     118
    119119                case ALL_HOST:
    120120                                /* This is more complex, we need to match with all candidates in each rule, it'll be done later */
    121121                        break;
    122                        
     122
    123123                case ALL_USER:
    124124                        {
     
    137137                        }
    138138                        break;
    139                
     139
    140140                default:
    141141                        ASSERT(0);
     
    153153        struct rtd_candidate * c_oh = NULL;
    154154        int cmp;
    155        
     155
    156156        TRACE_ENTRY("%p %p %p", e, msg, candidates);
    157157        ASSERT( e && msg && candidates );
    158        
     158
    159159        if (FD_IS_LIST_EMPTY(candidates)) {
    160160                TRACE_DEBUG(ANNOYING, "Skip Redirect rule since candidates list is empty");
    161161                return 0;
    162162        }
    163        
     163
    164164        /* Now search common peers between e->target_peers_list and candidates */
    165165        TRACE_DEBUG(ANNOYING, "Message %p matches a Redirect rule (t:%d, @%p), processing candidates list", msg, e->type, e);
    166        
     166
    167167        /* First, decrease the score of the host that we received the previous Redirect from, in case it is in the list */
    168168        for (lic = candidates->next; lic != candidates; lic = lic->next) {
    169169                struct rtd_candidate * cand = (struct rtd_candidate *) lic;
    170                
     170
    171171                /* Special case: ALL_HOST rules: we decrease the score of the Origin-Host if present */
    172172                if (e->type == ALL_HOST) {
     
    179179                        }
    180180                }
    181                
     181
    182182                cmp = fd_os_cmp(cand->diamid, cand->diamidlen, e->from.s, e->from.l);
    183183                if (!cmp) {
     
    185185                        cand->score += FD_SCORE_SENT_REDIRECT;
    186186                }
    187                
    188         }
    189        
     187
     188        }
     189
    190190        if ((e->type == ALL_HOST) && (c_oh == NULL)) {
    191191                /* The rule does not apply, we're done */
    192192                return 0;
    193193        }
    194        
     194
    195195        /* for each candidate, if it is found in the target_peers list, we add the rule's score to this candidate */
    196196        for (lic = candidates->next; lic != candidates; lic = lic->next) {
    197197                /* the candidates list is not guaranteed to be ordered at this time, so we cannot avoid the two imbricated loops */
    198198                struct rtd_candidate * cand = (struct rtd_candidate *) lic;
    199                
     199
    200200                /* Is this candidate in the "Redirect-Host" list ? We must search caseinsentive here. */
    201201                for (lirh = e->target_peers_list.next; lirh != &e->target_peers_list; lirh = lirh->next) {
    202202                        struct redir_host * host = lirh->o;
    203203                        int cont;
    204                        
     204
    205205                        cmp = fd_os_almostcasesrch( cand->diamid, cand->diamidlen, host->id, host->len, &cont );
    206                        
     206
    207207                        if (cmp == 0) {
    208208                                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);
     
    214214                }
    215215        }
    216        
     216
    217217        return 0;
    218218}
     
    224224        int i, ret = 0;
    225225        struct msg * msg = *pmsg;
    226        
     226
    227227        TRACE_ENTRY("%p %p %p", cbdata, msg, candidates);
    228        
     228
    229229        for (i = 0; i <= H_U_MAX; i++) {
    230230                /* Lock the line. We write lock in case of DONT_CACHE so we can directly unlink the entry. read in other cases is sufficient */
     
    234234                        CHECK_POSIX( pthread_rwlock_rdlock( &redirects_usages[i].lock ) );
    235235                }
    236                
     236
    237237                if (!FD_IS_LIST_EMPTY(&redirects_usages[i].sentinel)) {
    238238                        union matchdata data;
    239239                        int nodata; /* The message does not allow to apply this rule, skip */
    240                        
     240
    241241                        /* Retrieve the data that may match in the message */
    242242                        CHECK_FCT_DO( ret = get_data_to_match(i, msg, &data, &nodata), goto out );
    243                        
     243
    244244                        /* If this message may match some of our rules */
    245245                        if (!nodata) {
     
    248248                                for (li = redirects_usages[i].sentinel.next; li != &redirects_usages[i].sentinel; li = li->next) {
    249249                                        struct redir_entry * e = li->o;
    250                                        
     250
    251251                                        /* Does it match ? */
    252252                                        if (i != ALL_HOST) { /* this one is an exception, we handle it separately */
     
    257257                                                        break;
    258258                                        }
    259                                        
     259
    260260                                        /* This rule matches (or we are in ALL_HOST), apply */
    261261                                        CHECK_FCT_DO( ret = apply_rule(e, msg, candidates), goto out );
    262                                        
     262
    263263                                        /* If this was a DONT_CACHE rule, we unlink it, so that it will not be used again */
    264264                                        if (i == DONT_CACHE) {
    265265                                                li=li->prev;
    266266                                                fd_list_unlink( li->next );
    267                                                 /* We cannot delete here without taking the mutex, which would mean we have first to release the lock... 
     267                                                /* We cannot delete here without taking the mutex, which would mean we have first to release the lock...
    268268                                                        just let expiry garbage collet the rule */
    269269                                        }
    270270                                }
    271271                        }
    272                
    273                 }
    274 out:           
     272
     273                }
     274out:
    275275                CHECK_POSIX( pthread_rwlock_unlock( &redirects_usages[i].lock ) );
    276276                if (ret)
    277277                        return ret;
    278278        }
    279        
     279
    280280        return 0;
    281281}
Note: See TracChangeset for help on using the changeset viewer.