Merge lp:~jamesodhunt/libnih/inotify-overflow-fix into lp:libnih/1.0

Proposed by James Hunt on 2011-04-26
Status: Needs review
Proposed branch: lp:~jamesodhunt/libnih/inotify-overflow-fix
Merge into: lp:libnih/1.0
Diff against target: 41 lines (+16/-0)
2 files modified
ChangeLog (+8/-0)
nih/watch.c (+8/-0)
To merge this branch: bzr merge lp:~jamesodhunt/libnih/inotify-overflow-fix
Reviewer Review Type Date Requested Status
Scott James Remnant (Canonical) 2011-04-26 Pending
Review via email: mp+59094@code.launchpad.net

Description of the change

* nih/watch.c: nih_watch_reader(): Handle situation where kernel
  is generating events faster than can be consumed by simply
  ignoring them. Failure to do so results in an assertion failure in
  nih_watch_handle_by_wd() since the inotify_event object will
  contain an invalid watch descriptor (-1).

Note that running the shell script below will cause Upstart to crash (generally within 60 seconds with a reasonable system) as a result of this bug:

  while [ : ]
  do
    touch /etc/init/*
  done

To post a comment you must log in.

Unmerged revisions

1049. By James Hunt on 2011-04-26

* nih/watch.c: nih_watch_reader(): Handle situation where kernel
  is generating events faster than can be consumed by simply
  ignoring them. Failure to do so results in an assertion failure in
  nih_watch_handle_by_wd() since the inotify_event object will
  contain an invalid watch descriptor (-1).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2010-12-23 22:06:15 +0000
3+++ ChangeLog 2011-04-26 15:51:42 +0000
4@@ -1,3 +1,11 @@
5+2011-04-26 James Hunt <james.hunt@ubuntu.com>
6+
7+ * nih/watch.c: nih_watch_reader(): Handle situation where kernel
8+ is generating events faster than can be consumed by simply
9+ ignoring them. Failure to do so results in an assertion failure in
10+ nih_watch_handle_by_wd() since the inotify_event object will
11+ contain an invalid watch descriptor (-1).
12+
13 2010-12-23 Scott James Remnant <scott@netsplit.com>
14
15 * configure.ac: Bump version to 1.0.4
16
17=== modified file 'nih/watch.c'
18--- nih/watch.c 2011-01-06 09:28:39 +0000
19+++ nih/watch.c 2011-04-26 15:51:42 +0000
20@@ -424,6 +424,13 @@
21 if (len < sz)
22 goto finish;
23
24+ /* Handle situation where kernel is generating events faster
25+ * than can be consumed. Inotify will (somewhat ironically)
26+ * generate an event to signify this, so ignore it.
27+ */
28+ if (event->mask & IN_Q_OVERFLOW)
29+ goto consume;
30+
31 /* Find the handle for this watch */
32 handle = nih_watch_handle_by_wd (watch, event->wd);
33 if (handle)
34@@ -437,6 +444,7 @@
35 if (caught_free)
36 return;
37
38+consume:
39 /* Remove the event from the front of the buffer, and
40 * decrease our own length counter.
41 */

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: