MCPcopy Create free account
hub / github.com/F-Stack/f-stack / HouseKeeping

Function HouseKeeping

freebsd/netinet/libalias/alias_db.c:2099–2138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2097*/
2098
2099void
2100HouseKeeping(struct libalias *la)
2101{
2102 int i, n;
2103#ifndef _KERNEL
2104 struct timeval tv;
2105#endif
2106
2107 LIBALIAS_LOCK_ASSERT(la);
2108 /*
2109 * Save system time (seconds) in global variable timeStamp for use
2110 * by other functions. This is done so as not to unnecessarily
2111 * waste timeline by making system calls.
2112 */
2113#ifdef _KERNEL
2114 la->timeStamp = time_uptime;
2115#else
2116 gettimeofday(&tv, NULL);
2117 la->timeStamp = tv.tv_sec;
2118#endif
2119
2120 /* Compute number of spokes (output table link chains) to cover */
2121 n = LINK_TABLE_OUT_SIZE * (la->timeStamp - la->lastCleanupTime);
2122 n /= ALIAS_CLEANUP_INTERVAL_SECS;
2123
2124 /* Handle different cases */
2125 if (n > 0) {
2126 if (n > ALIAS_CLEANUP_MAX_SPOKES)
2127 n = ALIAS_CLEANUP_MAX_SPOKES;
2128 la->lastCleanupTime = la->timeStamp;
2129 for (i = 0; i < n; i++)
2130 IncrementalCleanup(la);
2131 } else if (n < 0) {
2132#ifdef LIBALIAS_DEBUG
2133 fprintf(stderr, "PacketAlias/HouseKeeping(): ");
2134 fprintf(stderr, "something unexpected in time values\n");
2135#endif
2136 la->lastCleanupTime = la->timeStamp;
2137 }
2138}
2139
2140/* Init the log file and enable logging */
2141static int

Callers 2

LibAliasInLockedFunction · 0.85
LibAliasOutLockedFunction · 0.85

Calls 1

IncrementalCleanupFunction · 0.85

Tested by

no test coverage detected