summaryrefslogtreecommitdiffstats
path: root/third_party/libevent
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 22:13:22 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 22:13:22 +0000
commit3efc167c513079b80765dcdac8dbeaf6c27e43b3 (patch)
tree557208292fb5331b8e9cb0f6b5753476a2c13adb /third_party/libevent
parentfa5dfaff1d203ab3fb692b6cd2bf0bdb67b1059c (diff)
downloadchromium_src-3efc167c513079b80765dcdac8dbeaf6c27e43b3.zip
chromium_src-3efc167c513079b80765dcdac8dbeaf6c27e43b3.tar.gz
chromium_src-3efc167c513079b80765dcdac8dbeaf6c27e43b3.tar.bz2
Linux: stop libevent from pre-allocating huge arrays.
Currently, libevent allocates two structures of size RLIMIT_NOFILE (which is 8192 on Ubuntu) and so these end up being several hundred kB of memory for each MessageLoopIO. This patch changes the default size to 32. If the thread watches a file descriptor greater than 32, the arrays will be grown as needed, doubling each time. Also fixes a typo in the upstream code. A bug report for this has been sent upstream. http://codereview.chromium.org/118126 BUG=11999 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libevent')
-rw-r--r--third_party/libevent/epoll.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/third_party/libevent/epoll.c b/third_party/libevent/epoll.c
index bfb3140..e9eacfb 100644
--- a/third_party/libevent/epoll.c
+++ b/third_party/libevent/epoll.c
@@ -94,7 +94,7 @@ const struct eventop epollops = {
#define FD_CLOSEONEXEC(x)
#endif
-#define NEVENT 32000
+#define NEVENT 32
/* On Linux kernels at least up to 2.6.24.4, epoll can't handle timeout
* values bigger than (LONG_MAX - 999ULL)/HZ. HZ in the wild can be
@@ -115,16 +115,6 @@ epoll_init(struct event_base *base)
if (getenv("EVENT_NOEPOLL"))
return (NULL);
- if (getrlimit(RLIMIT_NOFILE, &rl) == 0 &&
- rl.rlim_cur != RLIM_INFINITY) {
- /*
- * Solaris is somewhat retarded - it's important to drop
- * backwards compatibility when making changes. So, don't
- * dare to put rl.rlim_cur here.
- */
- nfiles = rl.rlim_cur - 1;
- }
-
/* Initalize the kernel queue */
if ((epfd = epoll_create(nfiles)) == -1) {
@@ -226,7 +216,7 @@ epoll_dispatch(struct event_base *base, void *arg, struct timeval *tv)
struct event *evread = NULL, *evwrite = NULL;
int fd = events[i].data.fd;
- if (fd < 0 && fd >= epollop->nfds)
+ if (fd < 0 || fd >= epollop->nfds)
continue;
evep = &epollop->fds[fd];