DBD-cubrid
view release on metacpan or search on metacpan
cci-src/src/cci/cci_handle_mng.c view on Meta::CPAN
ip_addr[0] = (unsigned char) ip0;
ip_addr[1] = (unsigned char) ip1;
ip_addr[2] = (unsigned char) ip2;
ip_addr[3] = (unsigned char) ip3;
}
static int
is_ip_str (char *ip_str)
{
char *p;
for (p = ip_str; *p; p++)
{
if ((*p >= '0' && *p <= '9') || (*p == '.'))
{
continue;
}
return 0;
}
return 1;
}
static void
hm_set_host_status_by_addr (unsigned char *ip_addr, int port, bool is_reachable)
{
int i;
MUTEX_LOCK (host_status_mutex);
i = hm_find_host_status_index (ip_addr, port);
if (i < 0)
{
i = host_status_count;
memcpy (host_status[i].host.ip_addr, ip_addr, 4);
host_status[i].host.port = port;
host_status_count++;
}
host_status[i].is_reachable = is_reachable;
MUTEX_UNLOCK (host_status_mutex);
}
static THREAD_RET_T THREAD_CALLING_CONVENTION
hm_thread_health_checker (void *arg)
{
int i;
unsigned char *ip_addr;
int port;
time_t start_time;
time_t elapsed_time;
while (1)
{
start_time = time (NULL);
for (i = 0; i < host_status_count; i++)
{
ip_addr = host_status[i].host.ip_addr;
port = host_status[i].host.port;
if (!host_status[i].is_reachable && net_check_broker_alive (ip_addr, port, BROKER_HEALTH_CHECK_TIMEOUT))
{
hm_set_host_status_by_addr (ip_addr, port, true);
}
}
elapsed_time = time (NULL) - start_time;
if (elapsed_time < MONITORING_INTERVAL)
{
SLEEP_MILISEC (MONITORING_INTERVAL - elapsed_time, 0);
}
}
return (THREAD_RET_T) 0;
}
void
hm_force_close_connection (T_CON_HANDLE * con_handle)
{
con_handle->alter_host_id = -1;
CLOSE_SOCKET (con_handle->sock_fd);
con_handle->sock_fd = INVALID_SOCKET;
con_handle->con_status = CCI_CON_STATUS_OUT_TRAN;
con_handle->force_failback = 0;
}
( run in 1.430 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )