From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4f594cbed02febd4f1086a3bf4b13bd9@iram.fr> To: 9fans@9fans.net From: "Mathieu Lonjaret" Date: Wed, 15 Sep 2010 10:15:10 +0200 In-Reply-To: <5b73ce333ceed4d8bb71f0e017f70cca@plug.quanstro.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-pfyzaikbcnjfqxercikbrvxidr" Subject: Re: [9fans] alt and chanfree Topicbox-Message-UUID: 57480f36-ead6-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-pfyzaikbcnjfqxercikbrvxidr Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I haven't tried chanclose() yet, but setting to nil the freed chan in the alt entry is not really what I wanted since it will make alt() return -1 (better than crashing but not ideal). In any case I found a satisfying workaround in my algorithm to solve that: when a thread is done using a chan, I keep track of it instead of calling chanfree(), and instead of allocating a new chan/alt when creating a new thread, I simply reuse one of the previously "abandonned" ones (if any is available). And I'll just free them all when the program terminates. Thanks to all, Mathieu --upas-pfyzaikbcnjfqxercikbrvxidr Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: mpl@smgl.fr.eu.org Delivered-To: mpl@smgl.fr.eu.org Received: by serenity.smgl.fr.eu.org (Postfix, from userid 65534) id 9199F32CFD; Tue, 14 Sep 2010 16:21:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on serenity.smgl.fr.eu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=1.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by serenity.smgl.fr.eu.org (Postfix) with ESMTP id 9CBAE32CDE for ; Tue, 14 Sep 2010 16:21:16 +0200 (CEST) Received: by eyx24 with SMTP id 24so4242405eyx.41 for ; Tue, 14 Sep 2010 07:21:16 -0700 (PDT) Received: by 10.213.28.205 with SMTP id n13mr2865351ebc.5.1284474076235; Tue, 14 Sep 2010 07:21:16 -0700 (PDT) X-Forwarded-To: mpl@smgl.fr.eu.org X-Forwarded-For: mathieu.lonjaret@gmail.com mpl@smgl.fr.eu.org Delivered-To: mathieu.lonjaret@gmail.com Received: by 10.14.47.140 with SMTP id t12cs114543eeb; Tue, 14 Sep 2010 07:21:15 -0700 (PDT) Received: by 10.114.12.15 with SMTP id 15mr1388134wal.134.1284474074338; Tue, 14 Sep 2010 07:21:14 -0700 (PDT) Received: from gouda.swtch.com (gouda.swtch.com [67.207.142.3]) by mx.google.com with ESMTP id e12si548135ibb.62.2010.09.14.07.21.13; Tue, 14 Sep 2010 07:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of 9fans-bounces+mathieu.lonjaret=gmail.com@9fans.net designates 67.207.142.3 as permitted sender) client-ip=67.207.142.3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of 9fans-bounces+mathieu.lonjaret=gmail.com@9fans.net designates 67.207.142.3 as permitted sender) smtp.mail=9fans-bounces+mathieu.lonjaret=gmail.com@9fans.net Received: from localhost ([127.0.0.1] helo=gouda.swtch.com) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from <9fans-bounces@9fans.net>) id 1OvWMj-0007zB-0y; Tue, 14 Sep 2010 14:20:09 +0000 Received: from ladd.quanstro.net ([69.55.170.73]) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from ) id 1OvWMf-0007z6-54 for 9fans@9fans.net; Tue, 14 Sep 2010 14:20:06 +0000 From: erik quanstrom Date: Tue, 14 Sep 2010 10:17:13 -0400 To: 9fans@9fans.net Message-ID: <5b73ce333ceed4d8bb71f0e017f70cca@plug.quanstro.net> In-Reply-To: References: <1c691961f042c7f6194f62781d377b4e@coraid.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] alt and chanfree X-BeenThere: 9fans@9fans.net X-Mailman-Version: 2.1.10 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces@9fans.net Errors-To: 9fans-bounces+mathieu.lonjaret=gmail.com@9fans.net > > isn't that what chanclose()/chanclosing() is for? > > > > - erik > > > > > > Not at all. Chanclose and chanclosing are to be used while the channel > still exists. > A closed channel is not a freed channel. Close/closing are useful for > synchronizing the cleanup > but no other operation should be done on a channel after it has been > freed because > the channel no longer exists. of course i ment using chanclose as the first step. the thread running the alt can free the closed channel. - erik --upas-pfyzaikbcnjfqxercikbrvxidr--