From astan.chee at al.com.au Fri Jun 5 09:16:17 2009 From: astan.chee at al.com.au (Astan Chee) Date: Fri, 5 Jun 2009 17:16:17 +1000 Subject: listing torrent files in btpd Message-ID: <4A28C641.2000905@al.com.au> Hi, I have btpd running with some torrents. Unfortunately they are writing to the same folder but each have different files. Is there a way to list what files are associated with which torrent in btpd? Does this make sense? Cheers Astan From axelgenus at gmail.com Fri Jun 5 09:42:45 2009 From: axelgenus at gmail.com (=?UTF-8?Q?Alessandro_Calor=C3=AC?=) Date: Fri, 5 Jun 2009 09:42:45 +0200 Subject: listing torrent files in btpd In-Reply-To: <4A28C641.2000905@al.com.au> References: <4A28C641.2000905@al.com.au> Message-ID: 2009/6/5 Astan Chee : > Hi, > I have btpd running with some torrents. Unfortunately they are writing > to the same folder but each have different files. You should specify a different directory for each torrent when you add them with btcli: Example: btcli add filename.torrent -d directory/to/use > Is there a way to list what files are associated with which torrent in btpd? Sorry, there's not any (with btpd). > Cheers > Astan Bye, Alessandro. From nemosoft at smcc.demon.nl Mon Jun 15 22:45:25 2009 From: nemosoft at smcc.demon.nl (Nemosoft Unv.) Date: Mon, 15 Jun 2009 22:45:25 +0200 Subject: Potiential resource leak in save_info() Message-ID: <200906152245.25833.nemosoft@smcc.demon.nl> Hello, While browsing through the btpd code, I noticed the following code in tlib.c, function save_info(): if ((fflush(fp) == EOF || fsync(fileno(fp)) != 0 || ferror(fp) || fclose(fp) != 0)) btpd_err("failed to write '%s'.\n", wpath); The nature of the C '||' operator is thus, that is evaluated left-to-right, and any statements after the first one that evaluates to 'true' are not executed. So, if fflush(), fsync() or ferror() return an error, the file 'fp' is never closed properly. Suppose there is a temporary condition (like disk full), btpd would slowly run out of file descriptors... I thinks it's better to call each function, store the result and then compare the return values: int e1 = fflush (fp); int e2 = fsync (fp); int e3 = ferror (fp); int e4 = fclose (fp); if (e1 == EOF || e2 != 0 ...) Something to consider for the next release... - Nemosoft From graue at oceanbase.org Mon Jun 15 22:51:18 2009 From: graue at oceanbase.org (Scott Feeney) Date: Mon, 15 Jun 2009 16:51:18 -0400 Subject: Potiential resource leak in save_info() In-Reply-To: <200906152245.25833.nemosoft@smcc.demon.nl> Message-ID: Nemosoft, Your concerns are moot because btpd_err() quits the program. Scott On 6/15/2009, "Nemosoft Unv." wrote: >Hello, > >While browsing through the btpd code, I noticed the following code in tlib.c, >function save_info(): > > if ((fflush(fp) == EOF || fsync(fileno(fp)) != 0 > || ferror(fp) || fclose(fp) != 0)) > btpd_err("failed to write '%s'.\n", wpath); > >The nature of the C '||' operator is thus, that is evaluated left-to-right, >and any statements after the first one that evaluates to 'true' are not >executed. So, if fflush(), fsync() or ferror() return an error, the file 'fp' >is never closed properly. Suppose there is a temporary condition (like disk >full), btpd would slowly run out of file descriptors... I thinks it's better >to call each function, store the result and then compare the return values: > > int e1 = fflush (fp); > int e2 = fsync (fp); > int e3 = ferror (fp); > int e4 = fclose (fp); > if (e1 == EOF || e2 != 0 ...) > >Something to consider for the next release... > > - Nemosoft >_______________________________________________ >btpd-users mailing list >btpd-users at murmeldjur.se >http://lists.stargirl.org/listinfo/btpd-users From nemosoft at smcc.demon.nl Mon Jun 15 23:33:09 2009 From: nemosoft at smcc.demon.nl (Nemosoft Unv.) Date: Mon, 15 Jun 2009 23:33:09 +0200 Subject: Potiential resource leak in save_info() In-Reply-To: References: Message-ID: <200906152333.10047.nemosoft@smcc.demon.nl> On Monday 15 June 2009 22:51:18 Scott Feeney wrote: > Nemosoft, > > Your concerns are moot because btpd_err() quits the program. Erhm, right. Methinks that function should be renamed to btpd_Fatal() then, since btpd_err() suggest it just logs an error, not quit. And maybe I code a bit too much on the defensive side, but I don't think it's really nice to depend on exit() to close your file descriptors. Oh well... - Nemosoft