cache_handler
[utility_handlers]

Maintains a cache of data for use by lower level handlers. [詳細]

関数

netsnmp_cachenetsnmp_cache_get_head (void)
 get cache head
netsnmp_cachenetsnmp_cache_find_by_oid (oid *rootoid, int rootoid_len)
 find existing cache
netsnmp_cachenetsnmp_cache_create (int timeout, NetsnmpCacheLoad *load_hook, NetsnmpCacheFree *free_hook, oid *rootoid, int rootoid_len)
 returns a cache
unsigned int netsnmp_cache_timer_start (netsnmp_cache *cache)
 starts the recurring cache_load callback
void netsnmp_cache_timer_stop (netsnmp_cache *cache)
 stops the recurring cache_load callback
netsnmp_mib_handlernetsnmp_cache_handler_get (netsnmp_cache *cache)
 returns a cache handler that can be injected into a given handler chain.
netsnmp_mib_handlernetsnmp_get_cache_handler (int timeout, NetsnmpCacheLoad *load_hook, NetsnmpCacheFree *free_hook, oid *rootoid, int rootoid_len)
 returns a cache handler that can be injected into a given handler chain.
int netsnmp_cache_handler_register (netsnmp_handler_registration *reginfo, netsnmp_cache *cache)
 functionally the same as calling netsnmp_register_handler() but also injects a cache handler at the same time for you.
int netsnmp_register_cache_handler (netsnmp_handler_registration *reginfo, int timeout, NetsnmpCacheLoad *load_hook, NetsnmpCacheFree *free_hook)
 functionally the same as calling netsnmp_register_handler() but also injects a cache handler at the same time for you.
NETSNMP_STATIC_INLINE char * _build_cache_name (const char *name)
void netsnmp_cache_reqinfo_insert (netsnmp_cache *cache, netsnmp_agent_request_info *reqinfo, const char *name)
 Insert the cache information for a given request (PDU)
netsnmp_cachenetsnmp_cache_reqinfo_extract (netsnmp_agent_request_info *reqinfo, const char *name)
 Extract the cache information for a given request (PDU)
netsnmp_cachenetsnmp_extract_cache_info (netsnmp_agent_request_info *reqinfo)
 Extract the cache information for a given request (PDU)
int netsnmp_cache_check_expired (netsnmp_cache *cache)
 Check if the cache timeout has passed.
int netsnmp_cache_check_and_reload (netsnmp_cache *cache)
 Reload the cache if required
int netsnmp_cache_is_valid (netsnmp_agent_request_info *reqinfo, const char *name)
 Is the cache valid for a given request?
int netsnmp_is_cache_valid (netsnmp_agent_request_info *reqinfo)
 for backwards compat
int netsnmp_cache_helper_handler (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
 Implements the cache handler
void release_cached_resources (unsigned int regNo, void *clientargs)
 run regularly to automatically release cached resources.

説明

Maintains a cache of data for use by lower level handlers.

This helper checks to see whether the data has been loaded "recently" (according to the timeout for that particular cache) and calls the registered "load_cache" routine if necessary. The lower handlers can then work with this local cached data.

A timeout value of -1 will cause netsnmp_cache_check_expired() to always return true, and thus the cache will be reloaded for every request.

To minimze resource use by the agent, a periodic callback checks for expired caches, and will call the free_cache function for any expired cache.

The load_cache route should return a negative number if the cache was not successfully loaded. 0 or any positive number indicates successs.

Several flags can be set to affect the operations on the cache.

If NETSNMP_CACHE_DONT_INVALIDATE_ON_SET is set, the free_cache method will not be called after a set request has processed. It is assumed that the lower mib handler using the cache has maintained cache consistency.

If NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD is set, the free_cache method will not be called before the load_cache method is called. It is assumed that the load_cache routine will properly deal with being called with a valid cache.

If NETSNMP_CACHE_DONT_FREE_EXPIRED is set, the free_cache method will not be called with the cache expires. The expired flag will be set, but the valid flag will not be cleared. It is assumed that the load_cache routine will properly deal with being called with a valid cache.

If NETSNMP_CACHE_PRELOAD is set when a the cache handler is created, the cache load routine will be called immediately.

If NETSNMP_CACHE_DONT_AUTO_RELEASE is set, the periodic callback that checks for expired caches will skip the cache. The cache will only be checked for expiration when a request triggers the cache handler. This is useful if the cache has it's own periodic callback to keep the cache fresh.

If NETSNMP_CACHE_AUTO_RELOAD is set, a timer will be set up to reload the cache when it expires. This is useful for keeping the cache fresh, even in the absence of incoming snmp requests.

Here are some suggestions for some common situations.

Cached File: If your table is based on a file that may periodically change, you can test the modification date to see if the file has changed since the last cache load. To get the cache helper to call the load function for every request, set the timeout to -1, which will cause the cache to always report that it is expired. This means that you will want to prevent the agent from flushing the cache when it has expired, and you will have to flush it manually if you detect that the file has changed. To accomplish this, set the following flags:

NETSNMP_CACHE_DONT_FREE_EXPIRED NETSNMP_CACHE_DONT_AUTO_RELEASE

Constant (periodic) reload: If you want the cache kept up to date regularly, even if no requests for the table are received, you can have your cache load routine called periodically. This is very useful if you need to monitor the data for changes (eg a LastChanged object). You will need to prevent the agent from flushing the cache when it expires. Set the cache timeout to the frequency, in seconds, that you wish to reload your cache, and set the following flags:

NETSNMP_CACHE_DONT_FREE_EXPIRED NETSNMP_CACHE_DONT_AUTO_RELEASE NETSNMP_CACHE_AUTO_RELOAD


関数

int netsnmp_cache_check_and_reload ( netsnmp_cache cache  ) 

Reload the cache if required

cache_handler.c385 行で定義されています。

参照先 netsnmp_cache_check_expired()netsnmp_cache_s::valid.

参照元 netsnmp_cache_helper_handler().

int netsnmp_cache_check_expired ( netsnmp_cache cache  ) 

Check if the cache timeout has passed.

Sets and return the expired flag.

cache_handler.c370 行で定義されています。

参照先 atime_ready()netsnmp_cache_s::expiredNULLnetsnmp_cache_s::timeoutnetsnmp_cache_s::timestampnetsnmp_cache_s::valid.

参照元 netsnmp_cache_check_and_reload()release_cached_resources().

netsnmp_cache* netsnmp_cache_create ( int  timeout,
NetsnmpCacheLoad *  load_hook,
NetsnmpCacheFree *  free_hook,
oid *  rootoid,
int  rootoid_len 
)

returns a cache

cache_handler.c136 行で定義されています。

参照先 netsnmp_cache_s::enablednetsnmp_cache_s::free_cachenetsnmp_cache_s::load_cachenetsnmp_ds_get_int()netsnmp_cache_s::nextNULLnetsnmp_cache_s::prevnetsnmp_cache_s::rootoidnetsnmp_cache_s::rootoid_lensnmp_duplicate_objid()snmp_log()SNMP_MALLOC_TYPEDEFnetsnmp_cache_s::timeout.

参照元 netsnmp_get_cache_handler()netsnmp_get_timed_bare_stash_cache_handler().

netsnmp_cache* netsnmp_cache_find_by_oid ( oid *  rootoid,
int  rootoid_len 
)

find existing cache

cache_handler.c120 行で定義されています。

参照先 netsnmp_oid_equals()netsnmp_cache_s::nextNULLnetsnmp_cache_s::rootoidnetsnmp_cache_s::rootoid_len.

netsnmp_cache* netsnmp_cache_get_head ( void   ) 

get cache head

cache_handler.c112 行で定義されています。

netsnmp_mib_handler* netsnmp_cache_handler_get ( netsnmp_cache cache  ) 

returns a cache handler that can be injected into a given handler chain.

cache_handler.c247 行で定義されています。

参照先 netsnmp_mib_handler_s::flagsnetsnmp_cache_s::flagsMIB_HANDLER_AUTO_NEXTnetsnmp_mib_handler_s::myvoidnetsnmp_cache_helper_handler()netsnmp_cache_timer_start()netsnmp_create_handler()NULLnetsnmp_cache_s::valid.

参照元 netsnmp_cache_handler_register()netsnmp_get_cache_handler()netsnmp_get_timed_bare_stash_cache_handler().

int netsnmp_cache_handler_register ( netsnmp_handler_registration reginfo,
netsnmp_cache cache 
)

functionally the same as calling netsnmp_register_handler() but also injects a cache handler at the same time for you.

cache_handler.c295 行で定義されています。

参照先 netsnmp_cache_handler_get()netsnmp_inject_handler()netsnmp_register_handler()NULL.

int netsnmp_cache_helper_handler ( netsnmp_mib_handler handler,
netsnmp_handler_registration reginfo,
netsnmp_agent_request_info reqinfo,
netsnmp_request_info requests 
)

Implements the cache handler

next handler called automatically - 'AUTO_NEXT'

next handler called automatically - 'AUTO_NEXT'

next handler called automatically - 'AUTO_NEXT'

cache_handler.c420 行で定義されています。

参照先 netsnmp_cache_s::cache_hintnetsnmp_cache_s::enablednetsnmp_cache_s::flagsnetsnmp_mib_handler_s::flagsnetsnmp_cache_s::free_cachenetsnmp_handler_args_s::handlernetsnmp_handler_registration_s::handlerNamenetsnmp_cache_s::load_cachenetsnmp_cache_s::magicMIB_HANDLER_AUTO_NEXTnetsnmp_agent_request_info_s::modenetsnmp_mib_handler_s::myvoidnetsnmp_cache_check_and_reload()netsnmp_cache_is_valid()netsnmp_cache_reqinfo_insert()netsnmp_ds_get_boolean()netsnmp_request_set_error_all()NULLnetsnmp_handler_args_s::reginfonetsnmp_handler_args_s::reqinfonetsnmp_handler_args_s::requestsnetsnmp_handler_registration_s::rootoidnetsnmp_handler_registration_s::rootoid_lensnmp_log()netsnmp_cache_s::valid.

参照元 netsnmp_cache_handler_get().

int netsnmp_cache_is_valid ( netsnmp_agent_request_info reqinfo,
const char *  name 
)

Is the cache valid for a given request?

cache_handler.c402 行で定義されています。

参照先 netsnmp_cache_reqinfo_extract()netsnmp_cache_s::valid.

参照元 netsnmp_cache_helper_handler()netsnmp_is_cache_valid().

netsnmp_cache* netsnmp_cache_reqinfo_extract ( netsnmp_agent_request_info reqinfo,
const char *  name 
)

Extract the cache information for a given request (PDU)

cache_handler.c350 行で定義されています。

参照先 _build_cache_name()netsnmp_agent_get_list_data()SNMP_FREE.

参照元 netsnmp_cache_is_valid()netsnmp_extract_cache_info()netsnmp_stash_cache_helper().

void netsnmp_cache_reqinfo_insert ( netsnmp_cache cache,
netsnmp_agent_request_info reqinfo,
const char *  name 
)

Insert the cache information for a given request (PDU)

cache_handler.c333 行で定義されています。

参照先 _build_cache_name()netsnmp_agent_add_list_data()netsnmp_agent_get_list_data()netsnmp_create_data_list()NULLSNMP_FREE.

参照元 netsnmp_cache_helper_handler().

unsigned int netsnmp_cache_timer_start ( netsnmp_cache cache  ) 

starts the recurring cache_load callback

cache_handler.c191 行で定義されています。

参照先 netsnmp_cache_s::flagsNULLnetsnmp_cache_s::rootoidnetsnmp_cache_s::rootoid_lensnmp_alarm_register()snmp_log()netsnmp_cache_s::timeoutnetsnmp_cache_s::timer_id.

参照元 netsnmp_cache_handler_get().

void netsnmp_cache_timer_stop ( netsnmp_cache cache  ) 

stops the recurring cache_load callback

cache_handler.c226 行で定義されています。

参照先 netsnmp_cache_s::flagsNULLsnmp_alarm_unregister()snmp_log()netsnmp_cache_s::timer_id.

netsnmp_cache* netsnmp_extract_cache_info ( netsnmp_agent_request_info reqinfo  ) 

Extract the cache information for a given request (PDU)

cache_handler.c362 行で定義されています。

参照先 netsnmp_cache_reqinfo_extract().

netsnmp_mib_handler* netsnmp_get_cache_handler ( int  timeout,
NetsnmpCacheLoad *  load_hook,
NetsnmpCacheFree *  free_hook,
oid *  rootoid,
int  rootoid_len 
)

returns a cache handler that can be injected into a given handler chain.

cache_handler.c276 行で定義されています。

参照先 netsnmp_mib_handler_s::myvoidnetsnmp_cache_create()netsnmp_cache_handler_get()NULL.

参照元 netsnmp_register_cache_handler().

int netsnmp_is_cache_valid ( netsnmp_agent_request_info reqinfo  ) 

for backwards compat

netsnmp_cache_is_valid() is preferred.

cache_handler.c413 行で定義されています。

参照先 netsnmp_cache_is_valid().

int netsnmp_register_cache_handler ( netsnmp_handler_registration reginfo,
int  timeout,
NetsnmpCacheLoad *  load_hook,
NetsnmpCacheFree *  free_hook 
)

functionally the same as calling netsnmp_register_handler() but also injects a cache handler at the same time for you.

cache_handler.c308 行で定義されています。

参照先 netsnmp_get_cache_handler()netsnmp_inject_handler()netsnmp_register_handler()NULLnetsnmp_handler_registration_s::rootoidnetsnmp_handler_registration_s::rootoid_len.

void release_cached_resources ( unsigned int  regNo,
void *  clientargs 
)

run regularly to automatically release cached resources.

xxx - method to prevent cache from expiring while a request is being processed (e.g. delegated request). proposal: set a flag, which would be cleared when request finished (which could be acomplished by a dummy data list item in agent req info & custom free function).

cache_handler.c575 行で定義されています。

参照先 netsnmp_cache_s::flagsnetsnmp_cache_check_expired()netsnmp_cache_s::nextNULLnetsnmp_cache_s::valid.


net-snmpに対してSat Sep 5 13:14:29 2009に生成されました。  doxygen 1.4.7