zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_dc_update_proxy                                              *
 *                                                                            *
 * Purpose: updates changed proxy data in configuration cache and updates     *
 *          diff flags to reflect the updated data                            *
 *                                                                            *
 * Parameter: diff - [IN/OUT] the properties to update                        *
 *                                                                            *
 ******************************************************************************/
zbx_dc_update_proxy

Purpose: updates changed proxy data in configuration cache and updates
diff flags to reflect the updated data

Parameter: diff - [IN/OUT] the properties to update
zbx_dc_update_proxy Purpose : updates changed proxy data in configuration cache and updates diff flags to reflect the updated data Parameter : diff - [ IN / OUT ] the properties to update
void	zbx_dc_update_proxy(zbx_proxy_diff_t *diff)
{
	ZBX_DC_PROXY	*proxy;
	WRLOCK_CACHE;
	if (diff->lastaccess < config->proxy_lastaccess_ts)
		diff->lastaccess = config->proxy_lastaccess_ts;
	if (NULL != (proxy = (ZBX_DC_PROXY *)zbx_hashset_search(&config->proxies, &diff->hostid)))
	{
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTACCESS))
		{
			int	lost = 0;	
			if (0 != (diff->flags &
					(ZBX_FLAGS_PROXY_DIFF_UPDATE_HEARTBEAT | ZBX_FLAGS_PROXY_DIFF_UPDATE_CONFIG)))
			{
				int	delay = diff->lastaccess - proxy->lastaccess;
				if (NET_DELAY_MAX < delay)
					lost = 1;
			}
			if (0 == lost && proxy->lastaccess != diff->lastaccess)
				proxy->lastaccess = diff->lastaccess;
			diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTACCESS);
		}
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_VERSION))
		{
			if (proxy->version != diff->version)
				proxy->version = diff->version;
			else
				diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_VERSION);
		}
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_COMPRESS))
		{
			if (proxy->auto_compress == diff->compress)
				diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_COMPRESS);
			proxy->auto_compress = diff->compress;
		}
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTERROR))
		{
			proxy->last_version_error_time = diff->last_version_error_time;
			diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTERROR);
		}
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_PROXYDELAY))
		{
			proxy->proxy_delay = diff->proxy_delay;
			diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_PROXYDELAY);
		}
		if (0 != (diff->flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_SUPPRESS_WIN))
		{
			zbx_proxy_suppress_t	*ps_win = &proxy->nodata_win, *ds_win = &diff->nodata_win;
			if ((ps_win->flags & ZBX_PROXY_SUPPRESS_ACTIVE) != (ds_win->flags & ZBX_PROXY_SUPPRESS_ACTIVE))
			{
				ps_win->period_end = ds_win->period_end;
			}
			if (ps_win->flags != ds_win->flags)
				ps_win->flags = ds_win->flags;
			if (0 > ps_win->values_num)	
				ps_win->values_num = 0;	
			ps_win->values_num += ds_win->values_num;
			diff->flags &= (~ZBX_FLAGS_PROXY_DIFF_UPDATE_SUPPRESS_WIN);
		}
	}
	UNLOCK_CACHE;
}
void zbx_dc_update_proxy ( zbx_proxy_diff_t * diff ) { ZBX_DC_PROXY * proxy ; WRLOCK_CACHE ; if ( diff -> lastaccess < config -> proxy_lastaccess_ts ) diff -> lastaccess = config -> proxy_lastaccess_ts ; if ( NULL != ( proxy = ( ZBX_DC_PROXY * ) zbx_hashset_search ( & config -> proxies , & diff -> hostid ) ) ) { if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTACCESS ) ) { int lost = 0 ; if ( 0 != ( diff -> flags & ( ZBX_FLAGS_PROXY_DIFF_UPDATE_HEARTBEAT | ZBX_FLAGS_PROXY_DIFF_UPDATE_CONFIG ) ) ) { int delay = diff -> lastaccess - proxy -> lastaccess ; if ( NET_DELAY_MAX < delay ) lost = 1 ; } if ( 0 == lost && proxy -> lastaccess != diff -> lastaccess ) proxy -> lastaccess = diff -> lastaccess ; diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTACCESS ) ; } if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_VERSION ) ) { if ( proxy -> version != diff -> version ) proxy -> version = diff -> version ; else diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_VERSION ) ; } if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_COMPRESS ) ) { if ( proxy -> auto_compress == diff -> compress ) diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_COMPRESS ) ; proxy -> auto_compress = diff -> compress ; } if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTERROR ) ) { proxy -> last_version_error_time = diff -> last_version_error_time ; diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_LASTERROR ) ; } if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_PROXYDELAY ) ) { proxy -> proxy_delay = diff -> proxy_delay ; diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_PROXYDELAY ) ; } if ( 0 != ( diff -> flags & ZBX_FLAGS_PROXY_DIFF_UPDATE_SUPPRESS_WIN ) ) { zbx_proxy_suppress_t * ps_win = & proxy -> nodata_win , * ds_win = & diff -> nodata_win ; if ( ( ps_win -> flags & ZBX_PROXY_SUPPRESS_ACTIVE ) != ( ds_win -> flags & ZBX_PROXY_SUPPRESS_ACTIVE ) ) { ps_win -> period_end = ds_win -> period_end ; } if ( ps_win -> flags != ds_win -> flags ) ps_win -> flags = ds_win -> flags ; if ( 0 > ps_win -> values_num ) ps_win -> values_num = 0 ; ps_win -> values_num += ds_win -> values_num ; diff -> flags &= ( ~ ZBX_FLAGS_PROXY_DIFF_UPDATE_SUPPRESS_WIN ) ; } } UNLOCK_CACHE ; }
Function: zbx_dc_update_proxy                                              
                                                                            
 Purpose: updates changed proxy data in configuration cache and updates     
          diff flags to reflect the updated data                            
                                                                            
 Parameter: diff - [IN/OUT] the properties to update
Function : zbx_dc_update_proxy Purpose : updates changed proxy data in configuration cache and updates diff flags to reflect the updated data Parameter : diff - [ IN / OUT ] the properties to update
/* communication lost */ /* proxy last access in database is updated separately in  */ /* every ZBX_PROXY_LASTACCESS_UPDATE_FREQUENCY seconds     */ /* some new values was processed faster than old */ /* we will suppress more                         */