* Get the client given its client number (the key). Returns the entry, * or NULL if it's not found. * * Access to the list itself is synchronized via locks. However, access * to the entry returned by get_client() is NOT synchronized. This means * that there are potentially problems if a client uses multiple, * simultaneous connections to access url's within the same protection * space. Howe
| 768 | * one-time nonces anyway. |
| 769 | */ |
| 770 | static client_entry *get_client(unsigned long key, const request_rec *r) |
| 771 | { |
| 772 | int bucket; |
| 773 | client_entry *entry, *prev = NULL; |
| 774 | |
| 775 | |
| 776 | if (!key || !client_shm) return NULL; |
| 777 | |
| 778 | bucket = key % client_list->tbl_len; |
| 779 | entry = client_list->table[bucket]; |
| 780 | |
| 781 | apr_global_mutex_lock(client_lock); |
| 782 | |
| 783 | while (entry && key != entry->key) { |
| 784 | prev = entry; |
| 785 | entry = entry->next; |
| 786 | } |
| 787 | |
| 788 | if (entry && prev) { /* move entry to front of list */ |
| 789 | prev->next = entry->next; |
| 790 | entry->next = client_list->table[bucket]; |
| 791 | client_list->table[bucket] = entry; |
| 792 | } |
| 793 | |
| 794 | apr_global_mutex_unlock(client_lock); |
| 795 | |
| 796 | if (entry) { |
| 797 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01764) |
| 798 | "get_client(): client %lu found", key); |
| 799 | } |
| 800 | else { |
| 801 | ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01765) |
| 802 | "get_client(): client %lu not found", key); |
| 803 | } |
| 804 | |
| 805 | return entry; |
| 806 | } |
| 807 | |
| 808 | |
| 809 | /* A simple garbage-collecter to remove unused clients. It removes the |
no outgoing calls
no test coverage detected