Remove entries */
| 1194 | |
| 1195 | /* Remove entries */ |
| 1196 | static void |
| 1197 | tcp_log_expire(void *unused __unused) |
| 1198 | { |
| 1199 | struct tcp_log_id_bucket *tlb; |
| 1200 | struct tcp_log_id_node *tln; |
| 1201 | sbintime_t expiry_limit; |
| 1202 | int tree_locked; |
| 1203 | |
| 1204 | TCPLOG_EXPIREQ_LOCK(); |
| 1205 | if (callout_pending(&tcp_log_expireq_callout)) { |
| 1206 | /* Callout was reset. */ |
| 1207 | TCPLOG_EXPIREQ_UNLOCK(); |
| 1208 | return; |
| 1209 | } |
| 1210 | |
| 1211 | /* |
| 1212 | * Process entries until we reach one that expires too far in the |
| 1213 | * future. Look one second in the future. |
| 1214 | */ |
| 1215 | expiry_limit = getsbinuptime() + SBT_1S; |
| 1216 | tree_locked = TREE_UNLOCKED; |
| 1217 | |
| 1218 | while ((tln = STAILQ_FIRST(&tcp_log_expireq_head)) != NULL && |
| 1219 | tln->tln_expiretime <= expiry_limit) { |
| 1220 | if (!callout_active(&tcp_log_expireq_callout)) { |
| 1221 | /* |
| 1222 | * Callout was stopped. I guess we should |
| 1223 | * just quit at this point. |
| 1224 | */ |
| 1225 | TCPLOG_EXPIREQ_UNLOCK(); |
| 1226 | return; |
| 1227 | } |
| 1228 | |
| 1229 | /* |
| 1230 | * Remove the node from the head of the list and unlock |
| 1231 | * the list. Change the expiry time to SBT_MAX as a signal |
| 1232 | * to other threads that we now own this. |
| 1233 | */ |
| 1234 | STAILQ_REMOVE_HEAD(&tcp_log_expireq_head, tln_expireq); |
| 1235 | tln->tln_expiretime = SBT_MAX; |
| 1236 | TCPLOG_EXPIREQ_UNLOCK(); |
| 1237 | |
| 1238 | /* |
| 1239 | * Remove the node from the bucket. |
| 1240 | */ |
| 1241 | tlb = tln->tln_bucket; |
| 1242 | TCPID_BUCKET_LOCK(tlb); |
| 1243 | if (tcp_log_remove_id_node(NULL, NULL, tlb, tln, &tree_locked)) { |
| 1244 | tcp_log_id_validate_tree_lock(tree_locked); |
| 1245 | if (tree_locked == TREE_WLOCKED) |
| 1246 | TCPID_TREE_WUNLOCK(); |
| 1247 | else |
| 1248 | TCPID_TREE_RUNLOCK(); |
| 1249 | tree_locked = TREE_UNLOCKED; |
| 1250 | } |
| 1251 | |
| 1252 | /* Drop the INP reference. */ |
| 1253 | INP_WLOCK(tln->tln_inp); |
nothing calls this directly
no test coverage detected