Gentoo Archives: gentoo-amd64

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] Re: Too many open files in KTorrent
Date: Tue, 25 Apr 2006 17:44:29
Message-Id: pan.2006.04.25.17.41.45.982386@cox.net
In Reply to: [gentoo-amd64] Too many open files in KTorrent by "Nicolas MASSÉ"
1 Nicolas MASSÉ posted <200604251632.37748.nicolas27.masse@×××××××.net>,
2 excerpted below, on Tue, 25 Apr 2006 16:32:31 +0200:
3
4 > I had a problem today with KTorrent, when I tried to download a torrent
5 > with a lots of files in it. It gave me an error : "Too many open files".
6 > So I ran ulimit -n 32768 and started ktorrent from the shell but I have
7 > now the following errors in the console :
8 >
9 > QSocketNotifier: Socket descriptor too large for select()
10 > QSocketNotifier: Internal error
11 >
12 > In the man page from select(2) we can read :
13 >
14 > "The default size of FD_SETSIZE is currently 1024. In order to
15 > accommodate programs which might potentially use a larger number of open
16 > files with select, it is possible to increase this size by having the
17 > program define FD_SETSIZE before the inclusion of any header which
18 > includes <sys/types.h>."
19 >
20 > Don't you think it's a bit strange to have a maximum number of open
21 > files defined at runtime (ulimit) and another limit (a C constant)
22 > defined at compilation ?
23
24 No. Some reasonable default limit must be set, and 1024 is a reasonably
25 sane default. An app can override that default if necessary. For the
26 vast majority of applications, 1024 files should be plenty. Set the
27 default higher than that and you are just begging for a buggy application
28 to DoS the system. It's still possible to do it deliberately with an
29 override, but in that case it'd have to be a deliberate attack. The
30 default guards against the unintended.
31
32 > Do you think I should report this as a bug against KTorrent ? KDE ? Qt ?
33 > libc ? something else ?
34
35 I'd say KTorrent, as that's what's failing to change the normally
36 reasonable default, for the special case that is KTorrent. If it's simply
37 using a library there, as is possible, and the override needs to be in the
38 library, they can bug it upstream or ask you to do so. It's possible,
39 however, that the 1024 default is a reasonable limit for the library as
40 well, and ktorrent will need to statically link its own copy, with the
41 necessary change incorporated.
42
43 It may instead be more reasonable to change ktorrent to be more
44 conservative with the resources it has, using them more wisely. Instead
45 of doing them all at once, it may have to break the torrent up into 1024
46 file segments (actually less, given STDIN/OUT/ERR and any other
47 housekeeping FDs it may need), or simply handle them one by one. Maybe it
48 already does and the bug is that it's using exactly 1024, having forgotten
49 that STD* will normally use at least three descriptors.
50
51 --
52 Duncan - List replies preferred. No HTML msgs.
53 "Every nonfree program has a lord, a master --
54 and if you use the program, he is your master." Richard Stallman in
55 http://www.linuxdevcenter.com/pub/a/linux/2004/12/22/rms_interview.html
56
57
58 --
59 gentoo-amd64@g.o mailing list

Replies

Subject Author
Re: [gentoo-amd64] Re: Too many open files in KTorrent "Nicolas MASSÉ" <nicolas27.masse@×××××××.net>