cluther@supernet.dallas.haus.com (Clay Luther) (04/22/91)
Hello: I do not usually read this group, so please email replies to me at cluther@supernet.haus.com *or* cluther@ponder.csci.unt.edu. Thanks. I am working with a program that allows creates an telnet port which users can connect to and access a database interactively. Standard Berkeley socket stuff. This is on a sequent. However, when several users (around 8) begin to access the database, the program can no longer open the database files. The error returned is "too many files open". Checking NFILES in stdio.h reveals 20. There are only 5 files attached to the database that users would access, and the code only allows at most 2 files to be open by one user at any time. The transaction path follows: User 1 request -> files open -> process -> files closed -> User 2 request -> files open -> process -> files closed -> ... User n request -> ... -> User 1 request -> ... That is, each user is served in round-robin fashion, each accessing the database for a very short amount of time. Therefore, at most two files are open *at any time*. I have checked the code thoroughly for dangling open files...none exist (well, as far as I can tell). However, when about 8 users log onto the database, a 9th user will cause a "too many files open" error. The code will run indefinitely with up to 8 users logged on. I have begun to think that the sequent is charging 2 files, one for input and one for output, for each telnet connection to the program. Is this true? And if so, are there any work arounds, or will I have to restrict the maximum number of users my program can handle at one time due to a kernel limitation? Thanks! -- Clay Luther, Postmaster cluther@supernet.dallas.haus.com Harris Adacom Corporation cluther@enigma.dallas.haus.com Voice: 214/386-2356 MS 23, PO Box 809022, Dallas, Tx 75380-9022 Fax: 214/386-2159 Your mileage may vary. Void where prohibited.
curt@oasys.dt.navy.mil (Curt Welch) (04/23/91)
cluther@supernet.dallas.haus.com (Clay Luther) writes: >I do not usually read this group, so please email replies to me at >cluther@supernet.haus.com *or* cluther@ponder.csci.unt.edu. Thanks. You know, I hate it when people do this. If you care enough to post a message, can't you at least read the news group for the next week? >I have begun to think that the sequent is charging 2 files, one for input and >one for output, for each telnet connection to the program. Is this true? If the code is using pseudo ttys for each connection, then yes, it could use 2 (or maybe even 3) files for each connection. Normal TCP connections (socket(), connect()) to daemons only take one file descriptor per connection. (and only cost 1 unit out of 20). >And if so, are there any work arounds, or will I have to restrict the maximum >number of users my program can handle at one time due to a kernel limitation? I'd say your probably have a bug in your code. Write some debug code to test all the file descriptors from 1 to 20 when you get the too many files error. Do an fstat() on all file descriptors and print out the results. This will tell you how many files you have open and what they are. Once you see this output, you will probably be able to understand what the program is doing. If all else fails, use setdtablesize(2) to get around your problem. Curt Welch
csd35@seq1.keele.ac.uk (Jonathan Knight) (04/24/91)
From article <7253@oasys.dt.navy.mil>, by curt@oasys.dt.navy.mil (Curt Welch): > cluther@supernet.dallas.haus.com (Clay Luther) writes: >>I do not usually read this group, so please email replies to me at >>cluther@supernet.haus.com *or* cluther@ponder.csci.unt.edu. Thanks. > You know, I hate it when people do this. If you care enough to post > a message, can't you at least read the news group for the next week? Yep - I agree. > If all else fails, use setdtablesize(2) to get around your problem. Two other gotcha's. The kernal has a max number of open files variable, it's worth checking that. Then if you go for the setdtablesize() option you'll need to check the max number of processes that can have more than 20 descriptors and also what the max number of descriptors is. Then you'll either have to re-write your code because the stdio library has a max of 20 open files or you'll have to get the BSD4.3 stdio package and build that. I did the latter. -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.