static void save_endp(ARGV *argv) { int ttl; int fd; if (argv->argc != 5 || (ttl = atoi(argv->argv[1])) <= 0 || (fd = atoi(argv->argv[4])) <= 0) { msg_error("usage: save_endp ttl endpoint endp_props fd"); return; } if (DUP2(0, fd) < 0) msg_fatal("dup2(0, %d): %m", fd); scache_save_endp(scache, ttl, argv->argv[2], argv->argv[3], fd); }
void smtp_save_session(SMTP_STATE *state, int name_key_flags, int endp_key_flags) { SMTP_SESSION *session = state->session; int fd; /* * Encode the next-hop logical destination, if available. Reuse storage * that is also used for cache lookup queries. */ if (HAVE_NEXTHOP_STATE(state)) smtp_key_prefix(state->dest_label, SMTP_REUSE_KEY_DELIM_NA, state->iterator, name_key_flags); /* * Encode the physical endpoint name. Reuse storage that is also used for * cache lookup queries. */ smtp_key_prefix(state->endp_label, SMTP_REUSE_KEY_DELIM_NA, state->iterator, endp_key_flags); /* * Passivate the SMTP_SESSION object, destroying the object in the * process. Reuse storage that is also used for cache lookup results. */ fd = smtp_session_passivate(session, state->dest_prop, state->endp_prop); state->session = 0; /* * Save the session under the next-hop name, if available. * * XXX The logical to physical binding can be kept for as long as the DNS * allows us to (but that could result in the caching of lots of unused * bindings). The session should be idle for no more than 30 seconds or * so. */ if (HAVE_NEXTHOP_STATE(state)) scache_save_dest(smtp_scache, var_smtp_cache_conn, STR(state->dest_label), STR(state->dest_prop), STR(state->endp_label)); /* * Save every good session under its physical endpoint address. */ scache_save_endp(smtp_scache, var_smtp_cache_conn, STR(state->endp_label), STR(state->endp_prop), fd); }