void smtpd_resolve_init(int cache_size) { /* * Sanity check. */ if (smtpd_resolve_cache) msg_panic("smtpd_resolve_init: multiple initialization"); /* * Initialize the resolved address cache. Note: the cache persists across * SMTP sessions so we cannot make it dependent on session state. */ smtpd_resolve_cache = ctable_create(cache_size, resolve_pagein, resolve_pageout, (void *) 0); }
void smtpd_resolve_init(int cache_size) { /* * Flush a pre-existing cache. The smtpd_check test program requires this * after an address class change. */ if (smtpd_resolve_cache) ctable_free(smtpd_resolve_cache); /* * Initialize the resolved address cache. Note: the cache persists across * SMTP sessions so we cannot make it dependent on session state. */ smtpd_resolve_cache = ctable_create(cache_size, resolve_pagein, resolve_pageout, (void *) 0); }
int smtp_tls_policy_cache_query(DSN_BUF *why, SMTP_TLS_POLICY *tls, SMTP_ITERATOR *iter) { VSTRING *key; /* * Create an empty TLS Policy cache on the fly. */ if (policy_cache == 0) policy_cache = ctable_create(CACHE_SIZE, policy_create, policy_delete, (void *) 0); /* * Query the TLS Policy cache, with a search key that reflects our shared * values that also appear in other cache and table search keys. */ key = vstring_alloc(100); smtp_key_prefix(key, ":", iter, SMTP_KEY_FLAG_NEXTHOP | SMTP_KEY_FLAG_HOSTNAME | SMTP_KEY_FLAG_PORT); ctable_newcontext(policy_cache, (void *) iter); *tls = *(SMTP_TLS_POLICY *) ctable_locate(policy_cache, STR(key)); vstring_free(key); /* * Report errors. Both error and non-error results are cached. We must * therefore copy the cached DSN buffer content to the caller's buffer. */ if (tls->level == TLS_LEV_INVALID) { /* XXX Simplify this by implementing a "copy" primitive. */ dsb_update(why, STR(tls->why->status), STR(tls->why->action), STR(tls->why->mtype), STR(tls->why->mname), STR(tls->why->dtype), STR(tls->why->dtext), "%s", STR(tls->why->reason)); return (0); } else { return (1); } }