예제 #1
0
ret_t
chula_avl_mrproper (chula_avl_generic_t *avl,
                    chula_func_free_t    free_func)
{
	chula_avl_generic_node_t *node;
	chula_avl_generic_node_t *next;

	if (unlikely (avl == NULL))
		return ret_ok;

	node = node_first (avl);

	while (node) {
		next = node_next (node);

		/* Node content */
		if (free_func) {
			free_func (node->value);
		}

		/* Node itself */
		node_free (node, avl);

		node = next;
	}

	return ret_ok;
}
예제 #2
0
switch_status_t act(virtual_ip_t *vip)
{
    // if I'm the first in priority list
    if ( vip->node_id == node_first(vip->node_list)) {
        // become master
        vip->state = ST_MASTER;

        // set the ip to bind to
        if (utils_add_vip(vip->config.address,
                          vip->config.device) != SWITCH_STATUS_SUCCESS) {
            goto error;
        }

        // gratuitous arp request
        if (utils_send_gARP(vip->config.mac,
                            vip->config.address,
                            vip->config.device) != SWITCH_STATUS_SUCCESS) {

            utils_remove_vip(vip->config.address, vip->config.device);
            goto error;
        }

        // and I say it to all other nodes
        virtual_ip_send_state(vip);
        return SWITCH_STATUS_SUCCESS;
    }

error:
    switch_log_printf(SWITCH_CHANNEL_LOG,
                      SWITCH_LOG_ERROR,"Failed transition to MASTER!\n");
    go_down(vip);
    return SWITCH_STATUS_FALSE;

}
예제 #3
0
ret_t
chula_avl_generic_while (chula_avl_generic_t             *avl,
                         chula_avl_generic_while_func_t   func,
                         void                            *param,
                         chula_avl_generic_node_t       **key,
                         void                           **value)
{
	ret_t                     ret;
	chula_avl_generic_node_t *node = avl->root;

	if (avl->root == NULL) {
		return ret_ok;
	}

	node = node_first (avl);
	while (node) {
		if (key)
			*key = node;
		if (value)
			*value = node->value;

		ret = func (node, node->value, param);
		if (ret != ret_ok) return ret;

		node = node_next (node);
	}

	return ret_ok;
}
예제 #4
0
switch_status_t rback_stop(virtual_ip_t *vip)
{
    if ((vip->rollback_node_id == 0) ||
        (vip->rollback_node_id != node_first(vip->node_list))){
        vip->state = ST_MASTER;
    }
    return SWITCH_STATUS_SUCCESS;
}
예제 #5
0
switch_status_t react(virtual_ip_t *vip)
{
    // if I'm the first in priority list
    if ( vip->node_id == node_first(vip->node_list)) {
        // become master
        vip->state = ST_MASTER;

        // set the ip to bind to
        if (utils_add_vip(vip->config.address,
                          vip->config.device) != SWITCH_STATUS_SUCCESS) {
            goto error;
        }

        // gratuitous arp request
        if (utils_send_gARP(vip->config.mac,
                            vip->config.address,
                            vip->config.device) != SWITCH_STATUS_SUCCESS) {
            utils_remove_vip(vip->config.address, vip->config.device);
            goto error;
        }

        // sofia recover!!!
        for (int i=0; i< MAX_SOFIA_PROFILES; i++) {
            if (!strcmp(vip->config.profiles[i].name, "")) break;
            if (vip->config.profiles[i].autorecover == SWITCH_TRUE) {
                utils_recover(vip->config.profiles[i].name);
            }
        }

        // and I say it to all other nodes
        virtual_ip_send_state(vip);


    } else {
        // se è cascato il master e non devo reagire mi ripulisco la tabella
        for (int i=0; i< MAX_SOFIA_PROFILES; i++) {
            if (!strcmp(vip->config.profiles[i].name, "")) break;
            utils_clean_up_table(vip->runtime_uuid,
                                 vip->config.profiles[i].name);
        }
    }
    return SWITCH_STATUS_SUCCESS;

error:
    switch_log_printf(SWITCH_CHANNEL_LOG,
                      SWITCH_LOG_ERROR,"Failed transition to MASTER!\n");
    go_down(vip);
    return SWITCH_STATUS_FALSE;

}