~ubuntu-branches/ubuntu/raring/pulseaudio/raring

« back to all changes in this revision

Viewing changes to debian/patches/0022-inotify-wrapper-Quit-daemon-if-pid-file-is-removed.patch

  • Committer: Package Import Robot
  • Author(s): David Henningsson
  • Date: 2013-04-18 13:24:16 UTC
  • Revision ID: package-import@ubuntu.com-20130418132416-cdnps88gp6erhtqr
Tags: 1:3.0-0ubuntu6
0022-inotify-wrapper-Quit-daemon-if-pid-file-is-removed.patch:
Fix patch not to cause 100% CPU (LP: #1170313)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From a0695829bdc0e76ef35dd6c3ce00141b6e7863af Mon Sep 17 00:00:00 2001
 
1
From afd823b21c544eb4764d9e38f2f15e5a4f50ab7a Mon Sep 17 00:00:00 2001
2
2
From: David Henningsson <david.henningsson@canonical.com>
3
3
Date: Wed, 17 Apr 2013 16:07:32 +0200
4
4
Subject: [PATCH] inotify-wrapper: Quit daemon if pid file is removed
16
16
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
17
17
---
18
18
 src/Makefile.am                 |    1 +
19
 
 src/daemon/main.c               |   20 ++++++++-
20
 
 src/pulsecore/inotify-wrapper.c |   93 +++++++++++++++++++++++++++++++++++++++
21
 
 src/pulsecore/inotify-wrapper.h |   13 ++++++
22
 
 src/pulsecore/pid.c             |    5 +++
 
19
 src/daemon/main.c               |   20 +++++++-
 
20
 src/pulsecore/inotify-wrapper.c |  103 +++++++++++++++++++++++++++++++++++++++
 
21
 src/pulsecore/inotify-wrapper.h |   13 +++++
 
22
 src/pulsecore/pid.c             |    5 ++
23
23
 src/pulsecore/pid.h             |    1 +
24
 
 6 files changed, 131 insertions(+), 2 deletions(-)
 
24
 6 files changed, 141 insertions(+), 2 deletions(-)
25
25
 create mode 100644 src/pulsecore/inotify-wrapper.c
26
26
 create mode 100644 src/pulsecore/inotify-wrapper.h
27
27
 
28
28
Index: pulseaudio-3.0/src/Makefile.am
29
29
===================================================================
30
 
--- pulseaudio-3.0.orig/src/Makefile.am 2013-04-17 17:30:30.912840834 +0200
31
 
+++ pulseaudio-3.0/src/Makefile.am      2013-04-17 17:30:30.900840834 +0200
 
30
--- pulseaudio-3.0.orig/src/Makefile.am 2013-04-18 13:25:39.017144501 +0200
 
31
+++ pulseaudio-3.0/src/Makefile.am      2013-04-18 13:25:39.009144501 +0200
32
32
@@ -840,6 +840,7 @@
33
33
                pulsecore/fdsem.c pulsecore/fdsem.h \
34
34
                pulsecore/g711.c pulsecore/g711.h \
39
39
                pulsecore/modinfo.c pulsecore/modinfo.h \
40
40
Index: pulseaudio-3.0/src/daemon/main.c
41
41
===================================================================
42
 
--- pulseaudio-3.0.orig/src/daemon/main.c       2013-04-17 17:30:30.912840834 +0200
43
 
+++ pulseaudio-3.0/src/daemon/main.c    2013-04-17 17:30:30.904840834 +0200
 
42
--- pulseaudio-3.0.orig/src/daemon/main.c       2013-04-18 13:25:39.017144501 +0200
 
43
+++ pulseaudio-3.0/src/daemon/main.c    2013-04-18 13:25:39.009144501 +0200
44
44
@@ -74,6 +74,7 @@
45
45
 #include <pulsecore/core-rtclock.h>
46
46
 #include <pulsecore/core-scache.h>
113
113
Index: pulseaudio-3.0/src/pulsecore/inotify-wrapper.c
114
114
===================================================================
115
115
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
116
 
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.c      2013-04-17 17:30:30.904840834 +0200
117
 
@@ -0,0 +1,93 @@
 
116
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.c      2013-04-18 13:25:39.009144501 +0200
 
117
@@ -0,0 +1,103 @@
118
118
+#ifdef HAVE_CONFIG_H
119
119
+#include <config.h>
120
120
+#endif
145
145
+        pa_io_event_flags_t events,
146
146
+        void *userdata) {
147
147
+
 
148
+    struct {
 
149
+        struct inotify_event event;
 
150
+        char name[NAME_MAX+1];
 
151
+    } buf;
 
152
+
148
153
+    pa_inotify *i = userdata;
149
154
+    int pid_fd;
150
155
+
151
156
+    pa_assert(i);
152
157
+
 
158
+    if (pa_read(fd, &buf, sizeof(buf), NULL) < (int) sizeof(buf.event))
 
159
+        pa_log_warn("inotify did not read a full event.");
 
160
+    else
 
161
+        pa_log_debug("inotify callback, event mask: 0x%x", (int) buf.event.mask);
 
162
+
153
163
+    pid_fd = pa_open_cloexec(i->filename, O_RDONLY
154
164
+#ifdef O_NOFOLLOW
155
165
+                       |O_NOFOLLOW
183
193
+        return NULL;
184
194
+    }
185
195
+
186
 
+    if (inotify_add_watch(i->fd, filename, IN_ATTRIB|IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF) < 0) {
 
196
+    if (inotify_add_watch(i->fd, filename, IN_DELETE_SELF|IN_MOVE_SELF) < 0) {
187
197
+        pa_log("inotify_add_watch() failed: %s", pa_cstrerror(errno));
188
198
+        pa_inotify_stop(i);
189
199
+        return NULL;
211
221
Index: pulseaudio-3.0/src/pulsecore/inotify-wrapper.h
212
222
===================================================================
213
223
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
214
 
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.h      2013-04-17 17:30:30.904840834 +0200
 
224
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.h      2013-04-18 13:25:39.013144501 +0200
215
225
@@ -0,0 +1,13 @@
216
226
+#ifndef fooinotifywrapperhfoo
217
227
+#define fooinotifywrapperhfoo
228
238
+#endif
229
239
Index: pulseaudio-3.0/src/pulsecore/pid.c
230
240
===================================================================
231
 
--- pulseaudio-3.0.orig/src/pulsecore/pid.c     2013-04-17 17:30:30.912840834 +0200
232
 
+++ pulseaudio-3.0/src/pulsecore/pid.c  2013-04-17 17:30:30.908840834 +0200
 
241
--- pulseaudio-3.0.orig/src/pulsecore/pid.c     2013-04-18 13:25:39.017144501 +0200
 
242
+++ pulseaudio-3.0/src/pulsecore/pid.c  2013-04-18 13:25:39.013144501 +0200
233
243
@@ -183,6 +183,11 @@
234
244
 
235
245
 }
244
254
     int fd = -1;
245
255
Index: pulseaudio-3.0/src/pulsecore/pid.h
246
256
===================================================================
247
 
--- pulseaudio-3.0.orig/src/pulsecore/pid.h     2013-04-17 17:30:30.912840834 +0200
248
 
+++ pulseaudio-3.0/src/pulsecore/pid.h  2013-04-17 17:30:30.908840834 +0200
 
257
--- pulseaudio-3.0.orig/src/pulsecore/pid.h     2013-04-18 13:25:39.017144501 +0200
 
258
+++ pulseaudio-3.0/src/pulsecore/pid.h  2013-04-18 13:25:39.013144501 +0200
249
259
@@ -22,6 +22,7 @@
250
260
   USA.
251
261
 ***/