MCPcopy Create free account
hub / github.com/apache/httpd / gc

Function gc

modules/aaa/mod_auth_digest.c:813–859  ·  view source on GitHub ↗

A simple garbage-collecter to remove unused clients. It removes the * last entry in each bucket and updates the counters. Returns the * number of removed entries. */

Source from the content-addressed store, hash-verified

811 * number of removed entries.
812 */
813static long gc(server_rec *s)
814{
815 client_entry *entry, *prev;
816 unsigned long num_removed = 0, idx;
817
818 /* garbage collect all last entries */
819
820 for (idx = 0; idx < client_list->tbl_len; idx++) {
821 entry = client_list->table[idx];
822 prev = NULL;
823
824 if (!entry) {
825 /* This bucket is empty. */
826 continue;
827 }
828
829 while (entry->next) { /* find last entry */
830 prev = entry;
831 entry = entry->next;
832 }
833 if (prev) {
834 prev->next = NULL; /* cut list */
835 }
836 else {
837 client_list->table[idx] = NULL;
838 }
839 if (entry) { /* remove entry */
840 apr_status_t err;
841
842 err = rmm_free(client_rmm, entry);
843 num_removed++;
844
845 if (err) {
846 /* Nothing we can really do but log... */
847 ap_log_error(APLOG_MARK, APLOG_ERR, err, s, APLOGNO(10007)
848 "Failed to free auth_digest client allocation");
849 }
850 }
851 }
852
853 /* update counters and log */
854
855 client_list->num_entries -= num_removed;
856 client_list->num_removed += num_removed;
857
858 return num_removed;
859}
860
861
862/*

Callers 1

add_clientFunction · 0.85

Calls 2

rmm_freeFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected