From owner-freebsd-arch Fri Apr 28 10:16:40 2000 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id EFF9437B8FD for ; Fri, 28 Apr 2000 10:16:33 -0700 (PDT) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id TAA19951 for ; Fri, 28 Apr 2000 19:16:28 +0200 (CEST) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id TAA03875 for freebsd-arch@freebsd.org; Fri, 28 Apr 2000 19:16:26 +0200 (CEST) Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7]) by hub.freebsd.org (Postfix) with ESMTP id A299E37B5FC for ; Fri, 28 Apr 2000 10:14:59 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from archie@localhost) by bubba.whistle.com (8.9.3/8.9.2) id KAA73019 for freebsd-arch@freebsd.org; Fri, 28 Apr 2000 10:14:59 -0700 (PDT) From: Archie Cobbs Message-Id: <200004281714.KAA73019@bubba.whistle.com> Subject: timeout(9) question To: freebsd-arch@freebsd.org Date: Fri, 28 Apr 2000 10:14:59 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Question: Why doesn't the timeout(9) routine call the handler function at the same spl level that the timeout was registered? The way it works now, it seems like there's an unavoidable race condition. Suppose you have malloc()'d some struct foo and registered a timeout and your foo_* routines all run at splnet(). Here is the shutdown routine: /* called at splnet() */ void foo_shutdown(struct foo *f) { untimeout(foo_timeout, f, f->callout); free(f); } Now consider foo_timeout(): void foo_timeout(void *arg) { struct foo *f = arg; int s; s = splnet(); ..do whatever.. splx(s); } How do we know that someone didn't call foo_shutdown() between the time that the timeout handler called foo_timeout() and the splnet() statement? This assumes that splsoftclock does not include splnet .. is that correct? If not, replace splnet with something else not included. Another thing that bugs me is there's not an easy way to check if a timeout is already registered, eg: extern int timeout_registered(struct callout handle); -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message