open file descriptors
From: santoshjoseph73 (member45873_at_dbforums.com)
Date: 10/27/03
- Next message: Robert: "recv not completely overwriting last string"
- Previous message: jetmarc: "fork() children and share memory with them"
- Next in thread: Barry Margolin: "Re: open file descriptors"
- Reply: Barry Margolin: "Re: open file descriptors"
- Reply: nobody: "Re: open file descriptors"
- Reply: James Antill: "Re: open file descriptors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Oct 2003 14:35:17 -0500
I think this question has been posted before, but I don't think the
answers were clear.
The problem I have is I'm running a server on unix(solairs 2.7) and i'm
running out of sockets. I use the setulimit function like this
new_res.rlim_cur = res.rlim_max;
new_res.rlim_max = res.rlim_max;
if ( -1 == setrlimit(RLIMIT_NOFILE, &new_res) )
return 0;
and this sets the open file descriptor limit to 1024. The question what
should I do when I get a socket error on a accept and the error is
EMFILE (Too many open files).
Should I sleep for a bit (1 second) and retry the accept? But what
happened the connection that was being tried did it fail (so the client
would get an error?)
And how can I avoid this type of situation? Can I find out how many
open file descriptors are currently being used (in code) so I avoid
accepting new connections?
How do Unix web servers solve this problem?
Thanks,
-Santosh
-- Posted via http://dbforums.com
- Next message: Robert: "recv not completely overwriting last string"
- Previous message: jetmarc: "fork() children and share memory with them"
- Next in thread: Barry Margolin: "Re: open file descriptors"
- Reply: Barry Margolin: "Re: open file descriptors"
- Reply: nobody: "Re: open file descriptors"
- Reply: James Antill: "Re: open file descriptors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|