From owner-freebsd-current@FreeBSD.ORG Fri Nov 5 15:20:30 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 936D5106566C for ; Fri, 5 Nov 2010 15:20:30 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 46FAA8FC0C for ; Fri, 5 Nov 2010 15:20:29 +0000 (UTC) Received: by gxk9 with SMTP id 9so2300920gxk.13 for ; Fri, 05 Nov 2010 08:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=RWRpCeAxtoJJwmatjmo6OvY2M8e52NQspXayZQM0AWs=; b=gHpV1P9HVITa/j/9DgHyTpJwKMpbJTbFUVyjmHJkAwOfDWVlf8Kuu3vpeiTJEY5Jah bxfclmIsHTtQp4JM1V5CgmeQVpVzpcbugIAHrvP7RpO12tCmFQUIx7qaDgqh/V+E0r+g qvXFhYVfgcchwmkDpk9sz2fSkZrdcm3LzeORY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=fVF5+ieiLW4SodoBdva+R1WJXg58QssCFAIKcaQB4i6Q9J9CCIdSwhVyPZjIDpxDUs 6K9sQmzB2XSfMT9gNNUTPCKjQI75NBJN/R2wMBFYOqh4ypaiM19viMAXmIbvBoq/g0qm kq0chtPo2j+2x9JZv0lfpOFHfnoEi331Y7LiA= Received: by 10.150.215.17 with SMTP id n17mr1298427ybg.8.1288970429115; Fri, 05 Nov 2010 08:20:29 -0700 (PDT) Received: from mark-laptop-bsd.mark-home (Mail1.sandvine.com [64.7.137.162]) by mx.google.com with ESMTPS id p38sm2599839ybk.4.2010.11.05.08.20.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Nov 2010 08:20:27 -0700 (PDT) Date: Fri, 5 Nov 2010 11:20:09 -0400 From: Mark Johnston To: Nick Hibma Message-ID: <20101105152009.GB1437@mark-laptop-bsd.mark-home> References: <20101024231119.GA2123@mark-laptop-bsd.mark-home> <20101024231642.GB2123@mark-laptop-bsd.mark-home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-current@freebsd.org Subject: Re: [Patch] libfetch - closing the cached FTP connection X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 15:20:30 -0000 On Fri, Nov 05, 2010 at 09:38:24AM +0100, Nick Hibma wrote: > Mark, > > My 2 cents: Isn't it more appropriate to set FD_CLOEXEC on the fd? > > fcntl(fd, F_SETFD, FD_CLOEXEC); > > It doesn't sound like you ever want to have a cached connection be copied into the child. Mum and child calling daddy using the same phone line isn't going to make the conversation any easier for daddy. > > Cheers, > > Nick The problem is that libfetch's ftp functions use an interface set up by funopen(3), so functions like fetchGetURL return a FILE*. However, I can't use something like fileno(3) to get the descriptor to pass to fcntl, because libfetch's FILE * is actually a struct ftpio *, which is only in ftp.c, i.e. not in the headers. I think using fcntl is nicer than having a "close the cached connection" function, but I don't think I can get around this problem without changing something in libfetch. Thanks, -Mark