/* * Syntax of "pike_list" : * no nodes */ struct mi_root* mi_pike_list(struct mi_root* cmd_tree, void* param) { struct mi_root* rpl_tree; struct ip_node *ip; int i; rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN); if (rpl_tree==0) return 0; for( i=0 ; i<MAX_IP_BRANCHES ; i++ ) { if (get_tree_branch(i)==0) continue; lock_tree_branch(i); if ( (ip=get_tree_branch(i))!=NULL ) print_red_ips( ip, 0, &rpl_tree->node ); unlock_tree_branch(i); } return rpl_tree; }
void swap_routine( unsigned int ticks, void *param) { struct ip_node *node; int i; /* LM_DBG("entering \n"); */ for(i=0;i<MAX_IP_BRANCHES;i++) { node = get_tree_branch(i); if (node) { lock_tree_branch( i ); node = get_tree_branch(i); /* again, to avoid races */ if (node) refresh_node( node ); unlock_tree_branch( i ); } } }
static void collect_data(int options) { int i; g_max_hits = get_max_hits(); DBG("pike: collect_data"); // maybe try_lock first and than do the rest? for(i=0;i<MAX_IP_BRANCHES;i++) { if (get_tree_branch(i)==0) continue; DBG("pike: collect_data: branch %d", i); lock_tree_branch(i); if (get_tree_branch(i)) traverse_subtree( get_tree_branch(i), 0, options ); unlock_tree_branch(i); } }