SMTP_SESSION *smtp_reuse_addr(SMTP_STATE *state, int endp_key_flags) { SMTP_SESSION *session; int fd; /* * Don't look up an existing plaintext connection when a new connection * would (try to) use TLS. */ #ifdef USE_TLS if (state->tls->level > TLS_LEV_NONE) return (0); #endif /* * Look up the session by its IP address. This means that we have no * destination-to-address binding properties. */ smtp_key_prefix(state->endp_label, SMTP_REUSE_KEY_DELIM_NA, state->iterator, endp_key_flags); if ((fd = scache_find_endp(smtp_scache, STR(state->endp_label), state->endp_prop)) < 0) return (0); VSTRING_RESET(state->dest_prop); VSTRING_TERMINATE(state->dest_prop); /* * Re-activate the SMTP_SESSION object, and verify that the session is * still good. */ session = smtp_reuse_common(state, fd, STR(state->endp_label)); return (session); }
static void find_endp(ARGV *argv) { int fd; if (argv->argc != 2) { msg_error("usage: find_endp endpoint"); return; } if ((fd = scache_find_endp(scache, argv->argv[1], endp_prop)) >= 0) close(fd); }