zabbix-agent2/src/zabbix_server/server.c
/******************************************************************************
 *                                                                            *
 * Function: server_teardown                                                  *
 *                                                                            *
 * Purpose: terminate processes and destroy shared resources                  *
 *                                                                            *
 ******************************************************************************/
server_teardown

Purpose: terminate processes and destroy shared resources
server_teardown Purpose : terminate processes and destroy shared resources
static void	server_teardown(zbx_socket_t *listen_sock)
{
	int	i;
	char	*error = NULL;
	zbx_unset_child_signal_handler();
#ifdef HAVE_PTHREAD_PROCESS_SHARED
	zbx_locks_disable();
#endif
	zbx_ha_kill();
	for (i = 0; i < threads_num; i++)
	{
		if (!threads[i])
			continue;
		kill(threads[i], SIGKILL);
	}
	for (i = 0; i < threads_num; i++)
	{
		if (!threads[i])
			continue;
		zbx_thread_wait(threads[i]);
	}
	zbx_free(threads);
	zbx_free(threads_flags);
	zbx_set_child_signal_handler();
	if (SUCCEED != server_restart_logger(&error))
	{
		zbx_error("cannot restart logger: %s", error);
		zbx_free(error);
		exit(EXIT_FAILURE);
	}
	if (NULL != listen_sock)
		zbx_tcp_unlisten(listen_sock);
	zbx_tfc_destroy();
	zbx_vc_destroy();
	zbx_vmware_destroy();
	free_selfmon_collector();
	free_configuration_cache();
	free_database_cache(ZBX_SYNC_NONE);
#ifdef HAVE_PTHREAD_PROCESS_SHARED
	zbx_locks_enable();
#endif
	if (SUCCEED != zbx_ha_start(&error, ZBX_NODE_STATUS_STANDBY))
	{
		zabbix_log(LOG_LEVEL_CRIT, "cannot start HA manager: %s", error);
		zbx_free(error);
		exit(EXIT_FAILURE);
	}
}
static void server_teardown ( zbx_socket_t * listen_sock ) { int i ; char * error = NULL ; zbx_unset_child_signal_handler ( ) ; #ifdef HAVE_PTHREAD_PROCESS_SHARED zbx_locks_disable ( ) ; #endif zbx_ha_kill ( ) ; for ( i = 0 ; i < threads_num ; i ++ ) { if ( ! threads [ i ] ) continue ; kill ( threads [ i ] , SIGKILL ) ; } for ( i = 0 ; i < threads_num ; i ++ ) { if ( ! threads [ i ] ) continue ; zbx_thread_wait ( threads [ i ] ) ; } zbx_free ( threads ) ; zbx_free ( threads_flags ) ; zbx_set_child_signal_handler ( ) ; if ( SUCCEED != server_restart_logger ( & error ) ) { zbx_error ( " " , error ) ; zbx_free ( error ) ; exit ( EXIT_FAILURE ) ; } if ( NULL != listen_sock ) zbx_tcp_unlisten ( listen_sock ) ; zbx_tfc_destroy ( ) ; zbx_vc_destroy ( ) ; zbx_vmware_destroy ( ) ; free_selfmon_collector ( ) ; free_configuration_cache ( ) ; free_database_cache ( ZBX_SYNC_NONE ) ; #ifdef HAVE_PTHREAD_PROCESS_SHARED zbx_locks_enable ( ) ; #endif if ( SUCCEED != zbx_ha_start ( & error , ZBX_NODE_STATUS_STANDBY ) ) { zabbix_log ( LOG_LEVEL_CRIT , " " , error ) ; zbx_free ( error ) ; exit ( EXIT_FAILURE ) ; } }
Function: server_teardown                                                  
                                                                            
 Purpose: terminate processes and destroy shared resources
Function : server_teardown Purpose : terminate processes and destroy shared resources
/* hard kill all zabbix processes, no logging or other  */ /* Disable locks so main process doesn't hang on logging if a process was              */ /* killed during logging. The locks will be re-enabled after logger is reinitialized   */ /* restart logger because it could have been stuck in lock */ /* destroy shared caches */