Skip to content

Commit

Permalink
- Unregister a callout function (release a copied tSlot tree) when
Browse files Browse the repository at this point in the history
  release was done.  Callout function is the preparation for the case
  that command ("natptconfig show xlate copy") does not call this
  release-function.
  • Loading branch information
fujisawa committed Dec 19, 2002
1 parent 985bb09 commit ddd6a36
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions kame/sys/netinet6/natpt_tslot.c
@@ -1,4 +1,4 @@
/* $KAME: natpt_tslot.c,v 1.72 2002/12/18 12:06:13 fujisawa Exp $ */ /* $KAME: natpt_tslot.c,v 1.73 2002/12/19 04:50:19 fujisawa Exp $ */


/* /*
* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 and 2001 WIDE Project. * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 and 2001 WIDE Project.
Expand Down Expand Up @@ -78,6 +78,10 @@ static time_t natpt_TCPT_2MSL;
static time_t natpt_tcp_maxidle; static time_t natpt_tcp_maxidle;




static struct callout_handle xlate_ch
= CALLOUT_HANDLE_INITIALIZER(&xlate_ch);


struct tslhash struct tslhash
{ {
TAILQ_HEAD(tslhead,tSlot) tslhead; TAILQ_HEAD(tslhead,tSlot) tslhead;
Expand Down Expand Up @@ -997,11 +1001,12 @@ natpt_duplicateXLate()
struct tSlot *tslq, *tsln; struct tSlot *tslq, *tsln;
struct tcpstate *ts; struct tcpstate *ts;


#if 0
/* /*
* This check is unnecessary because translator call * This check became unnecessary because we release copied
* natpt_releaseXLate() always. * memory at each time this routine is called.
*/ */
#if 0
if (!TAILQ_EMPTY(&tsl_xlate_head)) { if (!TAILQ_EMPTY(&tsl_xlate_head)) {
natpt_error = EBUSY; natpt_error = EBUSY;
return (NULL); return (NULL);
Expand Down Expand Up @@ -1042,8 +1047,20 @@ natpt_duplicateXLate()
} }
splx(s); splx(s);


if (!TAILQ_EMPTY(&tsl_xlate_head)) if (!TAILQ_EMPTY(&tsl_xlate_head)) {
timeout(natpt_releaseXLate, (caddr_t)0, xlateTimer * hz);
/*
* If callout function is not registered, register it.
* Callout function is the preparation for the case
* that command ("natptconfig show xlate copy") does
* not call this relase-function.
*/
if ((xlate_ch.callout == NULL)
|| (xlate_ch.callout->c_func == NULL)) {
xlate_ch = timeout(natpt_releaseXLate, (void *)0,
xlateTimer * hz);
}
}


return ((caddr_t)&tsl_xlate_head); return ((caddr_t)&tsl_xlate_head);
} }
Expand All @@ -1063,6 +1080,15 @@ natpt_releaseXLate(void *ignored_arg)
} }


TAILQ_INIT(&tsl_xlate_head); TAILQ_INIT(&tsl_xlate_head);

/*
* If callout function is registered, unregister it because
* the job of this function was finished.
*/
if (xlate_ch.callout
&& (xlate_ch.callout->c_func != NULL)) {
untimeout(natpt_releaseXLate, (void *)0, xlate_ch);
}
} }




Expand Down

0 comments on commit ddd6a36

Please sign in to comment.