Messages in this thread | | | Date | Mon, 29 Nov 1999 21:33:40 -0800 (PST) | From | Sherwin Notario <> | Subject | RE: Poll Error |
| |
here is my test code......
#include <sys/resource.h> #include <asm/poll.h> #include <errno.h>
main (void) { struct pollfd pfds [10000]; int pollnum=257, retval; struct rlimit rlim;
getrlimit (RLIMIT_NOFILE, &rlim); printf ("Cur %d Max %d\n", rlim.rlim_cur, rlim.rlim_max); rlim.rlim_cur = rlim.rlim_max = 32768; if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) printf ("Error in setting max FDs %s\n", strerror(errno)); getrlimit (RLIMIT_NOFILE, &rlim); printf ("Cur %d Max %d\n", rlim.rlim_cur, rlim.rlim_max);
memset (pfds, 0, sizeof(struct pollfd)*10000);
for (;;) { retval = poll (pfds, pollnum, 10*1000); if (retval > 0) break; if (retval < 0) { printf ("Poll error %s\n", strerror(errno)); return (-1); } } }
with the above code (running as root) i was able to get the ff output:
Cur 1024 Max 1024 Cur 32768 Max 32768 Poll error Invalid argument
--- David Schwartz <davids@webmaster.com> wrote: > > Your code fragment is not large enough. For one > thing, it doesn't show > where 'pfds' comes from. Also, you need to run it as > root, since only root > can raise its resource limits. > > Send me an entire code fragment that is large > enough to compile. > > DS > > > -----Original Message----- > > From: Sherwin Notario > [mailto:sherwin_notario@yahoo.com] > > Sent: Monday, November 29, 1999 5:21 PM > > To: David Schwartz > > Subject: RE: Poll Error > > > > > > iam using kernel 2.2.5-15 > > > > yes, i modified file-max and inode-max of > /proc/sys/fs > > > > here is the code fragment: > > ... > > ... > > /* set to 32 K here */ > > rlim.rlim_cur = rlim.rlim_max = 32768; > > if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) > > printf ("Error in setting max FDs %s\n", > > strerror(errno)); > > ... > > ... > > for (;;) > > { > > /* for debugging, i modify pollnum */ > > lRetVal = poll (pfds, pollnum, 10*1000); > > if (lRetVal > 0) > > break; > > if (lRetVal < -1) > > { > > printf ("Poll error %s\n", > strerror(errno)); > > return (-1); > > } > > } > > ... > > > > when i run this (with pollnum > 256, the result is > > always: > > Poll error Invalid argument > > > > sherwin > > > > > > --- David Schwartz <davids@webmaster.com> wrote: > > > > i tried setting file-max to 32768 and > inode-max > > > to > > > > 65536. > > > > > > What kernel version did you use? And you are > doing > > > this through the > > > /proc/sys/fs interface? > > > > > > > i've also set NR_OPEN and NR_FILE to 32K (in > > > > limits.h and fs.h) then recompiled the kernel. > > > > > > Big mistake. Don't do that. > > > > > > > in my program, i was able to set the maximum > > > number > > > > of open files to 32K (though setrlimit()). but > > > when i > > > > call poll with nfds > 256, i still get error. > > > > > > What error do you get? Can you email me your > test > > > program? > > > > > > DS > > > > > > > --- David Schwartz <davids@webmaster.com> > wrote: > > > > > > > > > > There is no such limit in the poll > function. > > > You > > > > > won't run into problems > > > > > with it until you hit about 16,000 fds. You > will > > > > > not, of course, be able to > > > > > _open_ more than 256 files unless you adjust > > > your > > > > > per-process resource > > > > > limits. And you may not be able to create > more > > > than > > > > > about 10,000 unless you > > > > > adjust your system-wide inode and file > limits. > > > > > > > > > > DS > > > > > > > > > > > hi, > > > > > > > > > > > > iam writing a program that uses poll > function. > > > > > > > > > > > > int poll(struct pollfd *ufds, unsigned int > > > nfds, > > > > > int > > > > > > timeout) > > > > > > > > > > > > i will use it to check 10000 FDs. but it > > > only > > > > > allows > > > > > > me to check up to 256 FDs. > > > > > > > > > > > > is there a way for me to increase nfds ? > > > > > > > > > > > > sherwin > > > > > > > > > > __________________________________________________ > > > > > > Do You Yahoo!? > > > > > > Thousands of Stores. Millions of > Products. > > > All > > > > > in one place. > > > > > > Yahoo! Shopping: http://shopping.yahoo.com > > > > > > > > > > > > - > > > > > > To unsubscribe from this list: send the > line > > > > > "unsubscribe linux-kernel" in > > > > > > the body of a message to > > > > > majordomo@vger.rutgers.edu > > > > > > Please read the FAQ at > > > http://www.tux.org/lkml/ > > > > > > > > > > > > > > > > > > > > > - > > > > > To unsubscribe from this list: send the line > > > > > "unsubscribe linux-kernel" in > > > > > the body of a message to > > > majordomo@vger.rutgers.edu > > > > > Please read the FAQ at > http://www.tux.org/lkml/ > > > > > > > > > > > > > > __________________________________________________ > > > > Do You Yahoo!? > > > > Thousands of Stores. Millions of Products. > All > > > in one place. > > > > Yahoo! Shopping: http://shopping.yahoo.com > > > > > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Thousands of Stores. Millions of Products. All > in one place. > > Yahoo! Shopping: http://shopping.yahoo.com > > > >
__________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one place. Yahoo! Shopping: http://shopping.yahoo.com
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |