Removed even more function which where practically empty and took away
some function arguments which were not used.
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: James Yonan <james@openvpn.net>
| ... | ... |
@@ -165,12 +165,12 @@ hash_add (struct hash *hash, const void *key, void *value, bool replace) |
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
void |
| 168 |
-hash_remove_by_value (struct hash *hash, void *value, bool autolock) |
|
| 168 |
+hash_remove_by_value (struct hash *hash, void *value) |
|
| 169 | 169 |
{
|
| 170 | 170 |
struct hash_iterator hi; |
| 171 | 171 |
struct hash_element *he; |
| 172 | 172 |
|
| 173 |
- hash_iterator_init (hash, &hi, autolock); |
|
| 173 |
+ hash_iterator_init (hash, &hi); |
|
| 174 | 174 |
while ((he = hash_iterator_next (&hi))) |
| 175 | 175 |
{
|
| 176 | 176 |
if (he->value == value) |
| ... | ... |
@@ -221,7 +221,6 @@ void_ptr_compare_function (const void *key1, const void *key2) |
| 221 | 221 |
void |
| 222 | 222 |
hash_iterator_init_range (struct hash *hash, |
| 223 | 223 |
struct hash_iterator *hi, |
| 224 |
- bool autolock, |
|
| 225 | 224 |
int start_bucket, |
| 226 | 225 |
int end_bucket) |
| 227 | 226 |
{
|
| ... | ... |
@@ -233,7 +232,6 @@ hash_iterator_init_range (struct hash *hash, |
| 233 | 233 |
hi->hash = hash; |
| 234 | 234 |
hi->elem = NULL; |
| 235 | 235 |
hi->bucket = NULL; |
| 236 |
- hi->autolock = autolock; |
|
| 237 | 236 |
hi->last = NULL; |
| 238 | 237 |
hi->bucket_marked = false; |
| 239 | 238 |
hi->bucket_index_start = start_bucket; |
| ... | ... |
@@ -243,10 +241,9 @@ hash_iterator_init_range (struct hash *hash, |
| 243 | 243 |
|
| 244 | 244 |
void |
| 245 | 245 |
hash_iterator_init (struct hash *hash, |
| 246 |
- struct hash_iterator *hi, |
|
| 247 |
- bool autolock) |
|
| 246 |
+ struct hash_iterator *hi) |
|
| 248 | 247 |
{
|
| 249 |
- hash_iterator_init_range (hash, hi, autolock, 0, hash->n_buckets); |
|
| 248 |
+ hash_iterator_init_range (hash, hi, 0, hash->n_buckets); |
|
| 250 | 249 |
} |
| 251 | 250 |
|
| 252 | 251 |
static inline void |
| ... | ... |
@@ -88,7 +88,7 @@ bool hash_remove_fast (struct hash *hash, |
| 88 | 88 |
const void *key, |
| 89 | 89 |
uint32_t hv); |
| 90 | 90 |
|
| 91 |
-void hash_remove_by_value (struct hash *hash, void *value, bool autolock); |
|
| 91 |
+void hash_remove_by_value (struct hash *hash, void *value); |
|
| 92 | 92 |
|
| 93 | 93 |
struct hash_iterator |
| 94 | 94 |
{
|
| ... | ... |
@@ -98,18 +98,16 @@ struct hash_iterator |
| 98 | 98 |
struct hash_element *elem; |
| 99 | 99 |
struct hash_element *last; |
| 100 | 100 |
bool bucket_marked; |
| 101 |
- bool autolock; |
|
| 102 | 101 |
int bucket_index_start; |
| 103 | 102 |
int bucket_index_end; |
| 104 | 103 |
}; |
| 105 | 104 |
|
| 106 | 105 |
void hash_iterator_init_range (struct hash *hash, |
| 107 | 106 |
struct hash_iterator *hi, |
| 108 |
- bool autolock, |
|
| 109 | 107 |
int start_bucket, |
| 110 | 108 |
int end_bucket); |
| 111 | 109 |
|
| 112 |
-void hash_iterator_init (struct hash *hash, struct hash_iterator *iter, bool autolock); |
|
| 110 |
+void hash_iterator_init (struct hash *hash, struct hash_iterator *iter); |
|
| 113 | 111 |
struct hash_element *hash_iterator_next (struct hash_iterator *hi); |
| 114 | 112 |
void hash_iterator_delete_element (struct hash_iterator *hi); |
| 115 | 113 |
void hash_iterator_free (struct hash_iterator *hi); |
| ... | ... |
@@ -147,21 +145,12 @@ hash_bucket (struct hash *hash, uint32_t hv) |
| 147 | 147 |
return &hash->buckets[hv & hash->mask]; |
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
-static inline void |
|
| 151 |
-hash_bucket_lock (struct hash_bucket *bucket) |
|
| 152 |
-{
|
|
| 153 |
-} |
|
| 154 |
- |
|
| 155 |
-static inline void |
|
| 156 |
-hash_bucket_unlock (struct hash_bucket *bucket) |
|
| 157 |
-{
|
|
| 158 |
-} |
|
| 159 |
- |
|
| 160 | 150 |
static inline void * |
| 161 |
-hash_lookup_lock (struct hash *hash, const void *key, uint32_t hv) |
|
| 151 |
+hash_lookup (struct hash *hash, const void *key) |
|
| 162 | 152 |
{
|
| 163 | 153 |
void *ret = NULL; |
| 164 | 154 |
struct hash_element *he; |
| 155 |
+ uint32_t hv = hash_value (hash, key); |
|
| 165 | 156 |
struct hash_bucket *bucket = &hash->buckets[hv & hash->mask]; |
| 166 | 157 |
|
| 167 | 158 |
he = hash_lookup_fast (hash, bucket, key, hv); |
| ... | ... |
@@ -171,12 +160,6 @@ hash_lookup_lock (struct hash *hash, const void *key, uint32_t hv) |
| 171 | 171 |
return ret; |
| 172 | 172 |
} |
| 173 | 173 |
|
| 174 |
-static inline void * |
|
| 175 |
-hash_lookup (struct hash *hash, const void *key) |
|
| 176 |
-{
|
|
| 177 |
- return hash_lookup_lock (hash, key, hash_value (hash, key)); |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 | 174 |
/* NOTE: assumes that key is not a duplicate */ |
| 181 | 175 |
static inline void |
| 182 | 176 |
hash_add_fast (struct hash *hash, |
| ... | ... |
@@ -112,7 +112,6 @@ multi_create_instance_tcp (struct multi_context *m) |
| 112 | 112 |
const uint32_t hv = hash_value (hash, &mi->real); |
| 113 | 113 |
struct hash_bucket *bucket = hash_bucket (hash, hv); |
| 114 | 114 |
|
| 115 |
- hash_bucket_lock (bucket); |
|
| 116 | 115 |
he = hash_lookup_fast (hash, bucket, &mi->real, hv); |
| 117 | 116 |
|
| 118 | 117 |
if (he) |
| ... | ... |
@@ -128,8 +127,6 @@ multi_create_instance_tcp (struct multi_context *m) |
| 128 | 128 |
hash_add_fast (hash, bucket, &mi->real, hv, mi); |
| 129 | 129 |
|
| 130 | 130 |
mi->did_real_hash = true; |
| 131 |
- |
|
| 132 |
- hash_bucket_unlock (bucket); |
|
| 133 | 131 |
} |
| 134 | 132 |
|
| 135 | 133 |
#ifdef ENABLE_DEBUG |
| ... | ... |
@@ -51,7 +51,6 @@ multi_get_create_instance_udp (struct multi_context *m) |
| 51 | 51 |
const uint32_t hv = hash_value (hash, &real); |
| 52 | 52 |
struct hash_bucket *bucket = hash_bucket (hash, hv); |
| 53 | 53 |
|
| 54 |
- hash_bucket_lock (bucket); |
|
| 55 | 54 |
he = hash_lookup_fast (hash, bucket, &real, hv); |
| 56 | 55 |
|
| 57 | 56 |
if (he) |
| ... | ... |
@@ -81,8 +80,6 @@ multi_get_create_instance_udp (struct multi_context *m) |
| 81 | 81 |
} |
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 |
- hash_bucket_unlock (bucket); |
|
| 85 |
- |
|
| 86 | 84 |
#ifdef ENABLE_DEBUG |
| 87 | 85 |
if (check_debug_level (D_MULTI_DEBUG)) |
| 88 | 86 |
{
|
| ... | ... |
@@ -146,7 +146,7 @@ multi_reap_range (const struct multi_context *m, |
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 | 148 |
dmsg (D_MULTI_DEBUG, "MULTI: REAP range %d -> %d", start_bucket, end_bucket); |
| 149 |
- hash_iterator_init_range (m->vhash, &hi, true, start_bucket, end_bucket); |
|
| 149 |
+ hash_iterator_init_range (m->vhash, &hi, start_bucket, end_bucket); |
|
| 150 | 150 |
while ((he = hash_iterator_next (&hi)) != NULL) |
| 151 | 151 |
{
|
| 152 | 152 |
struct multi_route *r = (struct multi_route *) he->value; |
| ... | ... |
@@ -587,7 +587,7 @@ multi_uninit (struct multi_context *m) |
| 587 | 587 |
struct hash_iterator hi; |
| 588 | 588 |
struct hash_element *he; |
| 589 | 589 |
|
| 590 |
- hash_iterator_init (m->iter, &hi, true); |
|
| 590 |
+ hash_iterator_init (m->iter, &hi); |
|
| 591 | 591 |
while ((he = hash_iterator_next (&hi))) |
| 592 | 592 |
{
|
| 593 | 593 |
struct multi_instance *mi = (struct multi_instance *) he->value; |
| ... | ... |
@@ -723,7 +723,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int |
| 723 | 723 |
status_printf (so, PACKAGE_NAME " CLIENT LIST"); |
| 724 | 724 |
status_printf (so, "Updated,%s", time_string (0, 0, false, &gc_top)); |
| 725 | 725 |
status_printf (so, "Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since"); |
| 726 |
- hash_iterator_init (m->hash, &hi, true); |
|
| 726 |
+ hash_iterator_init (m->hash, &hi); |
|
| 727 | 727 |
while ((he = hash_iterator_next (&hi))) |
| 728 | 728 |
{
|
| 729 | 729 |
struct gc_arena gc = gc_new (); |
| ... | ... |
@@ -744,7 +744,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int |
| 744 | 744 |
|
| 745 | 745 |
status_printf (so, "ROUTING TABLE"); |
| 746 | 746 |
status_printf (so, "Virtual Address,Common Name,Real Address,Last Ref"); |
| 747 |
- hash_iterator_init (m->vhash, &hi, true); |
|
| 747 |
+ hash_iterator_init (m->vhash, &hi); |
|
| 748 | 748 |
while ((he = hash_iterator_next (&hi))) |
| 749 | 749 |
{
|
| 750 | 750 |
struct gc_arena gc = gc_new (); |
| ... | ... |
@@ -787,7 +787,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int |
| 787 | 787 |
status_printf (so, "TIME%c%s%c%u", sep, time_string (now, 0, false, &gc_top), sep, (unsigned int)now); |
| 788 | 788 |
status_printf (so, "HEADER%cCLIENT_LIST%cCommon Name%cReal Address%cVirtual Address%cBytes Received%cBytes Sent%cConnected Since%cConnected Since (time_t)", |
| 789 | 789 |
sep, sep, sep, sep, sep, sep, sep, sep); |
| 790 |
- hash_iterator_init (m->hash, &hi, true); |
|
| 790 |
+ hash_iterator_init (m->hash, &hi); |
|
| 791 | 791 |
while ((he = hash_iterator_next (&hi))) |
| 792 | 792 |
{
|
| 793 | 793 |
struct gc_arena gc = gc_new (); |
| ... | ... |
@@ -810,7 +810,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int |
| 810 | 810 |
|
| 811 | 811 |
status_printf (so, "HEADER%cROUTING_TABLE%cVirtual Address%cCommon Name%cReal Address%cLast Ref%cLast Ref (time_t)", |
| 812 | 812 |
sep, sep, sep, sep, sep, sep); |
| 813 |
- hash_iterator_init (m->vhash, &hi, true); |
|
| 813 |
+ hash_iterator_init (m->vhash, &hi); |
|
| 814 | 814 |
while ((he = hash_iterator_next (&hi))) |
| 815 | 815 |
{
|
| 816 | 816 |
struct gc_arena gc = gc_new (); |
| ... | ... |
@@ -849,7 +849,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int |
| 849 | 849 |
#ifdef PACKET_TRUNCATION_CHECK |
| 850 | 850 |
{
|
| 851 | 851 |
status_printf (so, "HEADER,ERRORS,Common Name,TUN Read Trunc,TUN Write Trunc,Pre-encrypt Trunc,Post-decrypt Trunc"); |
| 852 |
- hash_iterator_init (m->hash, &hi, true); |
|
| 852 |
+ hash_iterator_init (m->hash, &hi); |
|
| 853 | 853 |
while ((he = hash_iterator_next (&hi))) |
| 854 | 854 |
{
|
| 855 | 855 |
struct gc_arena gc = gc_new (); |
| ... | ... |
@@ -895,8 +895,6 @@ multi_learn_addr (struct multi_context *m, |
| 895 | 895 |
struct multi_route *oldroute = NULL; |
| 896 | 896 |
struct multi_instance *owner = NULL; |
| 897 | 897 |
|
| 898 |
- hash_bucket_lock (bucket); |
|
| 899 |
- |
|
| 900 | 898 |
/* if route currently exists, get the instance which owns it */ |
| 901 | 899 |
he = hash_lookup_fast (m->vhash, bucket, addr, hv); |
| 902 | 900 |
if (he) |
| ... | ... |
@@ -966,7 +964,6 @@ multi_learn_addr (struct multi_context *m, |
| 966 | 966 |
gc_free (&gc); |
| 967 | 967 |
} |
| 968 | 968 |
|
| 969 |
- hash_bucket_unlock (bucket); |
|
| 970 | 969 |
return owner; |
| 971 | 970 |
} |
| 972 | 971 |
|
| ... | ... |
@@ -1130,7 +1127,7 @@ multi_delete_dup (struct multi_context *m, struct multi_instance *new_mi) |
| 1130 | 1130 |
struct hash_element *he; |
| 1131 | 1131 |
int count = 0; |
| 1132 | 1132 |
|
| 1133 |
- hash_iterator_init (m->iter, &hi, true); |
|
| 1133 |
+ hash_iterator_init (m->iter, &hi); |
|
| 1134 | 1134 |
while ((he = hash_iterator_next (&hi))) |
| 1135 | 1135 |
{
|
| 1136 | 1136 |
struct multi_instance *mi = (struct multi_instance *) he->value; |
| ... | ... |
@@ -1768,7 +1765,7 @@ multi_bcast (struct multi_context *m, |
| 1768 | 1768 |
printf ("BCAST len=%d\n", BLEN (buf));
|
| 1769 | 1769 |
#endif |
| 1770 | 1770 |
mb = mbuf_alloc_buf (buf); |
| 1771 |
- hash_iterator_init (m->iter, &hi, true); |
|
| 1771 |
+ hash_iterator_init (m->iter, &hi); |
|
| 1772 | 1772 |
|
| 1773 | 1773 |
while ((he = hash_iterator_next (&hi))) |
| 1774 | 1774 |
{
|
| ... | ... |
@@ -2462,7 +2459,7 @@ management_callback_kill_by_cn (void *arg, const char *del_cn) |
| 2462 | 2462 |
struct hash_element *he; |
| 2463 | 2463 |
int count = 0; |
| 2464 | 2464 |
|
| 2465 |
- hash_iterator_init (m->iter, &hi, true); |
|
| 2465 |
+ hash_iterator_init (m->iter, &hi); |
|
| 2466 | 2466 |
while ((he = hash_iterator_next (&hi))) |
| 2467 | 2467 |
{
|
| 2468 | 2468 |
struct multi_instance *mi = (struct multi_instance *) he->value; |
| ... | ... |
@@ -2496,7 +2493,7 @@ management_callback_kill_by_addr (void *arg, const in_addr_t addr, const int por |
| 2496 | 2496 |
saddr.sa.sin_port = htons (port); |
| 2497 | 2497 |
if (mroute_extract_openvpn_sockaddr (&maddr, &saddr, true)) |
| 2498 | 2498 |
{
|
| 2499 |
- hash_iterator_init (m->iter, &hi, true); |
|
| 2499 |
+ hash_iterator_init (m->iter, &hi); |
|
| 2500 | 2500 |
while ((he = hash_iterator_next (&hi))) |
| 2501 | 2501 |
{
|
| 2502 | 2502 |
struct multi_instance *mi = (struct multi_instance *) he->value; |
| ... | ... |
@@ -638,7 +638,7 @@ pf_cn_set_print (const struct pf_cn_set *s, const int lev) |
| 638 | 638 |
|
| 639 | 639 |
if (s->hash_table) |
| 640 | 640 |
{
|
| 641 |
- hash_iterator_init (s->hash_table, &hi, false); |
|
| 641 |
+ hash_iterator_init (s->hash_table, &hi); |
|
| 642 | 642 |
while ((he = hash_iterator_next (&hi))) |
| 643 | 643 |
{
|
| 644 | 644 |
struct pf_cn *e = (struct pf_cn *)he->value; |