aboutsummaryrefslogtreecommitdiffstats
path: root/src/kqueue.c
diff options
context:
space:
mode:
authorMichael Albinus2016-03-04 14:01:36 +0000
committerMichael Albinus2016-03-04 14:01:36 +0000
commit484967796755051c4045cdcc26b0d3d129cc72ad (patch)
treec2fc0747c640beb5f6056494728e775bf9c20883 /src/kqueue.c
parentca4e30058eba0531f38fff75f14734acffab84ea (diff)
downloademacs-484967796755051c4045cdcc26b0d3d129cc72ad.tar.gz
emacs-484967796755051c4045cdcc26b0d3d129cc72ad.zip
Fix Bug#22814
* lisp/autorevert.el (global-auto-revert-mode): Do not set `auto-revert-use-notify' to nil. * etc/NEWS: Mention this. * etc/PROBLEMS: Remove problem Bug#22814. * src/kqueue.c: Include <sys/resource.h>. (Fkqueue_add_watch): Limit the number of used file descriptors. (Bug#22814) * test/lisp/filenotify-tests.el (file-notify--test-remote-enabled) (file-notify-test00-availability, file-notify-test01-add-watch) (file-notify-test02-events, file-notify-test06-many-events): Use #' read syntax for functions. (file-notify-test05-dir-validity) (file-notify-test06-many-events): Simplify directory creation. (file-notify-test09-sufficient-ressources): New test.
Diffstat (limited to 'src/kqueue.c')
-rw-r--r--src/kqueue.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/kqueue.c b/src/kqueue.c
index a69d06da3ae..7e3bfdd5746 100644
--- a/src/kqueue.c
+++ b/src/kqueue.c
@@ -29,6 +29,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include "keyboard.h" 29#include "keyboard.h"
30#include "process.h" 30#include "process.h"
31 31
32#ifdef HAVE_SYS_RESOURCE_H
33#include <sys/resource.h>
34#endif /* HAVE_SYS_RESOURCE_H */
35
32 36
33/* File handle for kqueue. */ 37/* File handle for kqueue. */
34static int kqueuefd = -1; 38static int kqueuefd = -1;
@@ -368,9 +372,12 @@ only when the upper directory of the renamed file is watched. */)
368 (Lisp_Object file, Lisp_Object flags, Lisp_Object callback) 372 (Lisp_Object file, Lisp_Object flags, Lisp_Object callback)
369{ 373{
370 Lisp_Object watch_object, dir_list; 374 Lisp_Object watch_object, dir_list;
371 int fd, oflags; 375 int maxfd, fd, oflags;
372 u_short fflags = 0; 376 u_short fflags = 0;
373 struct kevent kev; 377 struct kevent kev;
378#ifdef HAVE_GETRLIMIT
379 struct rlimit rlim;
380#endif /* HAVE_GETRLIMIT */
374 381
375 /* Check parameters. */ 382 /* Check parameters. */
376 CHECK_STRING (file); 383 CHECK_STRING (file);
@@ -383,6 +390,21 @@ only when the upper directory of the renamed file is watched. */)
383 if (! FUNCTIONP (callback)) 390 if (! FUNCTIONP (callback))
384 wrong_type_argument (Qinvalid_function, callback); 391 wrong_type_argument (Qinvalid_function, callback);
385 392
393 /* Check available file descriptors. */
394#ifdef HAVE_GETRLIMIT
395 if (! getrlimit (RLIMIT_NOFILE, &rlim))
396 maxfd = rlim.rlim_cur;
397 else
398#endif /* HAVE_GETRLIMIT */
399 maxfd = 256;
400
401 /* We assume 50 file descriptors are sufficient for the rest of Emacs. */
402 if ((maxfd - 50) < XINT (Flength (watch_list)))
403 xsignal2
404 (Qfile_notify_error,
405 build_string ("File watching not possible, no file descriptor left"),
406 Flength (watch_list));
407
386 if (kqueuefd < 0) 408 if (kqueuefd < 0)
387 { 409 {
388 /* Create kqueue descriptor. */ 410 /* Create kqueue descriptor. */