+int
+is_throttle_ip(struct sockaddr *addr)
+{
+ throttle_t *t;
+ rb_patricia_node_t *pnode;
+ int duration;
+
+ if((pnode = rb_match_ip(throttle_tree, addr)) != NULL)
+ {
+ t = pnode->data;
+ if(t->count > ConfigFileEntry.throttle_count)
+ {
+ duration = t->last + ConfigFileEntry.throttle_duration - rb_current_time();
+ return duration > 0 ? duration : 1;
+ }
+ }
+ return 0;
+}
+
+void
+flush_throttle(void)
+{
+ rb_dlink_node *ptr, *next;
+ rb_patricia_node_t *pnode;
+ throttle_t *t;
+
+ RB_DLINK_FOREACH_SAFE(ptr, next, throttle_list.head)
+ {
+ pnode = ptr->data;
+ t = pnode->data;
+
+ rb_dlinkDelete(ptr, &throttle_list);
+ rb_free(t);
+ rb_patricia_remove(throttle_tree, pnode);
+ }
+}
+