00001 /* 00002 * $Id: hslot.h 5241 2008-11-21 12:52:25Z henningw $ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /*! \file 00024 * \brief USRLOC - Hash table collision slot related functions 00025 * \ingroup usrloc 00026 */ 00027 00028 00029 00030 #ifndef HSLOT_H 00031 #define HSLOT_H 00032 00033 #include "../../locking.h" 00034 00035 #include "udomain.h" 00036 #include "urecord.h" 00037 00038 00039 struct udomain; 00040 struct urecord; 00041 00042 00043 typedef struct hslot { 00044 int n; /*!< Number of elements in the collision slot */ 00045 struct urecord* first; /*!< First element in the list */ 00046 struct urecord* last; /*!< Last element in the list */ 00047 struct udomain* d; /*!< Domain we belong to */ 00048 #ifdef GEN_LOCK_T_PREFERED 00049 gen_lock_t *lock; /*!< Lock for hash entry - fastlock */ 00050 #else 00051 int lockidx; /*!< Lock index for hash entry - the rest*/ 00052 #endif 00053 } hslot_t; 00054 00055 /*! \brief 00056 * Initialize slot structure 00057 */ 00058 void init_slot(struct udomain* _d, hslot_t* _s, int n); 00059 00060 00061 /*! \brief 00062 * Deinitialize given slot structure 00063 */ 00064 void deinit_slot(hslot_t* _s); 00065 00066 00067 /*! \brief 00068 * Add an element to slot linked list 00069 */ 00070 void slot_add(hslot_t* _s, struct urecord* _r); 00071 00072 00073 /*! \brief 00074 * Remove an element from slot linked list 00075 */ 00076 void slot_rem(hslot_t* _s, struct urecord* _r); 00077 00078 00079 /*! 00080 * \brief Initialize locks for the hash table 00081 * \return 0 on success, -1 on failure 00082 */ 00083 int ul_init_locks(void); 00084 00085 00086 /*! 00087 * \brief Destroy all locks on the list 00088 */ 00089 void ul_unlock_locks(void); 00090 void ul_destroy_locks(void); 00091 00092 #ifndef GEN_LOCK_T_PREFERED 00093 void ul_lock_idx(int idx); 00094 void ul_release_idx(int idx); 00095 #endif 00096 00097 #endif /* HSLOT_H */
1.5.6