Merge lp:~jamesh/mediascanner/ignore-inotify-event-for-deleted-directory into lp:mediascanner/v2

Proposed by James Henstridge
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: 191
Merged at revision: 190
Proposed branch: lp:~jamesh/mediascanner/ignore-inotify-event-for-deleted-directory
Merge into: lp:mediascanner/v2
Diff against target: 27 lines (+9/-0)
2 files modified
debian/rules (+3/-0)
src/daemon/SubtreeWatcher.cc (+6/-0)
To merge this branch: bzr merge lp:~jamesh/mediascanner/ignore-inotify-event-for-deleted-directory
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+197480@code.launchpad.net

Commit message

In SubtreeWatcher, ignore inotify events for watches we are no longer interested in.

Description of the change

In SubtreeWatcher.pumpEvents(), we weren't checking whether the inotify event's watch descriptor was one we actually cared about before looking it up in p->wd2str. This kind of access had the unwanted side effect of adding another entry to the map. The simple fix is to check for presence of the watch in the map first.

This problem showed up when building the package on the Launchpad PPA builder, where the inotify events from a directory removal seem to be delivered in a different order to what I see locally or in Jenkins. This makes it difficult to test without an entire stub inotify implementation.

This branch also updates the packaging to always include the test output in the build log even if the tests pass. This makes it easier to compare output in case of failures.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/rules'
2--- debian/rules 2013-11-05 13:06:00 +0000
3+++ debian/rules 2013-12-03 09:24:28 +0000
4@@ -11,3 +11,6 @@
5
6 %:
7 dh $@ --parallel --fail-missing
8+
9+override_dh_auto_test:
10+ dh_auto_test --max-parallel=1 -- ARGS="--verbose"
11
12=== modified file 'src/daemon/SubtreeWatcher.cc'
13--- src/daemon/SubtreeWatcher.cc 2013-11-28 03:08:09 +0000
14+++ src/daemon/SubtreeWatcher.cc 2013-12-03 09:24:28 +0000
15@@ -180,6 +180,12 @@
16 }
17 for(char *d = buf; d < buf + num_read;) {
18 struct inotify_event *event = (struct inotify_event *) d;
19+ if (p->wd2str.find(event->wd) == p->wd2str.end()) {
20+ // Ignore events for unknown watches. We may receive
21+ // such events when a directory is removed.
22+ d += sizeof(struct inotify_event) + event->len;
23+ continue;
24+ }
25 string directory = p->wd2str[event->wd];
26 string filename(event->name);
27 string abspath = directory + '/' + filename;

Subscribers

People subscribed via source and target branches