for t_template, allocate mbuf cluster only if really necessary.

this avoids too aggressive memory usage on heavy load web server, for example.
From: Kevin Lahey <kml@dotrocket.com>

release and reallocate t_template, if t_template->m_len changes.
(this happens if we connect to IPv4 mapped destination and then IPv6
destination, on a single AF_INET6 socket)

KAME 1.26 -> 1.28
This commit is contained in:
itojun 2000-09-19 18:21:41 +00:00
parent 3a4441e3d4
commit dde2adf8e4

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_subr.c,v 1.92 2000/06/30 16:44:34 itojun Exp $ */ /* $NetBSD: tcp_subr.c,v 1.93 2000/09/19 18:21:41 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -258,9 +258,19 @@ tcp_template(tp)
hlen = 0; /*pacify gcc*/ hlen = 0; /*pacify gcc*/
return NULL; /*EAFNOSUPPORT*/ return NULL; /*EAFNOSUPPORT*/
} }
if ((m = tp->t_template) == 0) { #ifdef DIAGNOSTIC
if (hlen + sizeof(struct tcphdr) > MCLBYTES)
panic("mclbytes too small for t_template");
#endif
m = tp->t_template;
if (m && m->m_len == hlen + sizeof(struct tcphdr))
;
else {
if (m)
m_freem(m);
m = tp->t_template = NULL;
MGETHDR(m, M_DONTWAIT, MT_HEADER); MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (m) { if (m && hlen + sizeof(struct tcphdr) > MHLEN) {
MCLGET(m, M_DONTWAIT); MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) { if ((m->m_flags & M_EXT) == 0) {
m_free(m); m_free(m);