Navigation



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

Store redirect information for ALL_SESSION and ALL_USER in a hash.

This is a speedup if many of these exist (compared to checking a
linked list for matches as before).

Refactor a bit while here.

Use the uthash code from Troy D. Hanson,
http://troydhanson.github.com/uthash/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rt_redirect/rt_redir.h

    r1259 r1260  
    11/*********************************************************************************************************
    22* Software License Agreement (BSD License)                                                               *
    3 * Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    4 *                                                                                                        *
    5 * Copyright (c) 2013, WIDE Project and NICT                                                              *
     3* Author: Sebastien Decugis <sdecugis@freediameter.net> and                                              *
     4* Thomas Klausner <tk@giga.or.at>                                                                        *
     5*                                                                                                        *
     6* Copyright (c) 2013, 2014, WIDE Project and NICT                                                        *
    67* All rights reserved.                                                                                   *
    78*                                                                                                        *
     
    3637/* Diameter Redirect management */
    3738#include <freeDiameter/extension.h>
     39
     40#include "uthash.h"
    3841
    3942/* There are 2 locks in this module. The priority is established as follow to avoid deadlocks:
     
    130133        struct fd_list   target_peers_list; /* The list of Redirect-Hosts for this entry */
    131134
    132         struct timespec  timeout;  /* When does this entry expires? */
     135        struct timespec  timeout;  /* When does this entry expire? */
    133136        struct fd_list   exp_list; /* chain in the expire_list list, ordered by expiration date, protected by exp_peer_lock */
    134137
    135         enum redir_h_u type;  /* Type of this entry */
     138        enum redir_h_u type;       /* Type of this entry */
    136139        struct fd_list redir_list; /* link in redirects_usages lists. Lists are ordered by the data value. Protected by rw locks */
    137         union matchdata data;   /* The strings are duplicated & must be freed in this structure */
     140        union matchdata data;      /* The strings are duplicated & must be freed in this structure */
     141        UT_hash_handle hh;         /* magic entry for hash table */
    138142};
    139143
     
    145149};
    146150extern struct redir_line redirects_usages[];
     151/* the hash table where entries are stored for ALL_SESSION and ALL_USER */
     152extern struct redir_entry *redirect_hash_table[];
    147153
    148154/* Accelerator to the line lock */
     
    158164/* Functions on redir_entry */
    159165int redir_entry_init();
     166int redir_entry_fini();
    160167int redir_entry_new(struct redir_entry ** e, struct fd_list * targets, uint32_t rhu, struct msg * qry, DiamId_t nh, size_t nhlen, os0_t oh, size_t ohlen);
    161168extern int (*redir_entry_cmp_key[])(union matchdata * , union matchdata *); /* compare functions */
Note: See TracChangeset for help on using the changeset viewer.