From owner-freebsd-arch Tue Feb 4 8:43:49 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F8EA37B401 for ; Tue, 4 Feb 2003 08:43:48 -0800 (PST) Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2567A43F75 for ; Tue, 4 Feb 2003 08:43:47 -0800 (PST) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Tue, 4 Feb 2003 16:43:36 +0000 Received: from cmjg (helo=localhost) by mail.ilrt.bris.ac.uk with local-esmtp (Exim 3.16 #1) id 18g69h-0005uH-00; Tue, 04 Feb 2003 16:42:41 +0000 Date: Tue, 4 Feb 2003 16:42:41 +0000 (GMT) From: Jan Grant X-X-Sender: cmjg@mail.ilrt.bris.ac.uk To: Chip Norkus Cc: arch@freebsd.org Subject: Re: dlclose() vs. atexit() In-Reply-To: <20030204162513.GB22642@arpa.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 4 Feb 2003, Chip Norkus wrote: > On Tue Feb 04, 2003; 10:46AM -0500 Mikhail Teterin propagated the following: > > [snip] > > > > Yet another plan would be to have the atexit() call simply increase the > > ref-count of the library a handler is from, so it will not actually be > > unloaded by dlclose(). But that will be yet another implementation... > > > > I'm not sure this would be a good idea. I have a program which > uses dynamic libraries to introduce code, and which can unload or > reload them at any time and keep on running. I am especially worried > about the reload case, because what often happens is that an old > version of the .so is unloaded (dlclosed) and then a new version > is loaded (dlopened). If the old version stays around, I'm afraid > there would be some symbol collision. Correct me if I'm wrong, > though. > > I think the Solaris approach you mentioned above is by far the best > and most correct sounding approach. I agree; I've done similar work with dlopened libraries which were "updated" over time, dynamically. The atexit() / dlclose() behaviour seems robust and "does the right thing". If you want more complex behaviour (eg, persisting library state while you update a dynamic library) then you have to roll your own. That's not a big deal. -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/ There's no convincing English-language argument that this sentence is true. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message