mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-10-28 14:24:31 +00:00
- corosync-device-net as binary is gone. Replacement is
corosync-qdevice
- corosync-qdevice has support for multiple models (only net is
currently implemented)
- Completelly redesign qdevice-net main loop.
- Connect is non blocking
- Cmap and Votequorum events are handled even before connect to
qnetd. Algorithm gets send_node_list and vote set so it's not needed
to check connection status and also vote_timer is running and voting
until something changes (configuration or votequorum node list)
- If connect fails, algorithm_disconnected with new reason
CANT_CONNECT_TO_THE_SERVER is called
- Logging for qdevice is based on libqb logging functions. Also
logging configuration from corosync.conf is now used and dynamic
changes of configuration are handled.
- Added qdevice_net_algorithm_config_node_list_changed
- Changed qdevice_net_algorithm_votequorum_node_list_notify in respect
of adding send_node_list so it's similar to other functions.
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
137 lines
4.1 KiB
C
137 lines
4.1 KiB
C
/*
|
|
* Copyright (c) 2015-2016 Red Hat, Inc.
|
|
*
|
|
* All rights reserved.
|
|
*
|
|
* Author: Jan Friesse (jfriesse@redhat.com)
|
|
*
|
|
* This software licensed under BSD license, the text of which follows:
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are met:
|
|
*
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
* - Neither the name of the Red Hat, Inc. nor the names of its
|
|
* contributors may be used to endorse or promote products derived from this
|
|
* software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#include "qnet-config.h"
|
|
#include "qdevice-log.h"
|
|
#include "qdevice-net-cast-vote-timer.h"
|
|
#include "qdevice-votequorum.h"
|
|
|
|
static int
|
|
qdevice_net_cast_vote_timer_callback(void *data1, void *data2)
|
|
{
|
|
struct qdevice_net_instance *instance;
|
|
int cast_vote;
|
|
|
|
instance = (struct qdevice_net_instance *)data1;
|
|
|
|
switch (instance->cast_vote_timer_vote) {
|
|
case TLV_VOTE_ACK:
|
|
cast_vote = 1;
|
|
break;
|
|
case TLV_VOTE_NACK:
|
|
cast_vote = 0;
|
|
break;
|
|
case TLV_VOTE_ASK_LATER:
|
|
case TLV_VOTE_WAIT_FOR_REPLY:
|
|
case TLV_VOTE_NO_CHANGE:
|
|
default:
|
|
qdevice_log(LOG_CRIT, "qdevice_net_timer_cast_vote: Unhandled cast_vote_timer_vote %u\n",
|
|
instance->cast_vote_timer_vote);
|
|
exit(1);
|
|
break;
|
|
}
|
|
|
|
if (qdevice_votequorum_poll(instance->qdevice_instance_ptr, cast_vote) != 0) {
|
|
instance->disconnect_reason = QDEVICE_NET_DISCONNECT_REASON_CANT_SCHEDULE_VOTING_TIMER;
|
|
instance->schedule_disconnect = 1;
|
|
instance->cast_vote_timer = NULL;
|
|
return (0);
|
|
}
|
|
|
|
/*
|
|
* Schedule this function callback again
|
|
*/
|
|
return (-1);
|
|
}
|
|
|
|
int
|
|
qdevice_net_cast_vote_timer_update(struct qdevice_net_instance *instance, enum tlv_vote vote)
|
|
{
|
|
int timer_needs_running;
|
|
|
|
switch (vote) {
|
|
case TLV_VOTE_ACK:
|
|
case TLV_VOTE_NACK:
|
|
timer_needs_running = 1;
|
|
break;
|
|
case TLV_VOTE_WAIT_FOR_REPLY:
|
|
case TLV_VOTE_ASK_LATER:
|
|
timer_needs_running = 0;
|
|
break;
|
|
case TLV_VOTE_NO_CHANGE:
|
|
return (0);
|
|
|
|
break;
|
|
default:
|
|
qdevice_log(LOG_CRIT, "qdevice_net_cast_vote_timer_update_vote: Unhandled vote parameter %u\n",
|
|
vote);
|
|
exit(1);
|
|
break;
|
|
}
|
|
|
|
instance->cast_vote_timer_vote = vote;
|
|
|
|
if (timer_needs_running) {
|
|
if (instance->cast_vote_timer == NULL) {
|
|
instance->cast_vote_timer = timer_list_add(&instance->main_timer_list,
|
|
instance->cast_vote_timer_interval,
|
|
qdevice_net_cast_vote_timer_callback, (void *)instance, NULL);
|
|
|
|
if (instance->cast_vote_timer == NULL) {
|
|
qdevice_log(LOG_ERR, "Can't schedule sending of "
|
|
"votequorum poll");
|
|
|
|
return (-1);
|
|
} else {
|
|
qdevice_log(LOG_DEBUG, "Cast vote timer is now scheduled every "
|
|
"%"PRIu32"ms.", instance->cast_vote_timer_interval);
|
|
}
|
|
}
|
|
|
|
if (qdevice_net_cast_vote_timer_callback((void *)instance, NULL) != -1) {
|
|
return (-1);
|
|
}
|
|
} else {
|
|
if (instance->cast_vote_timer != NULL) {
|
|
timer_list_delete(&instance->main_timer_list, instance->cast_vote_timer);
|
|
instance->cast_vote_timer = NULL;
|
|
qdevice_log(LOG_DEBUG, "Cast vote timer is now stopped.");
|
|
} else {
|
|
qdevice_log(LOG_DEBUG, "Cast vote timer remains stopped.");
|
|
}
|
|
}
|
|
|
|
return (0);
|
|
}
|