Bugzilla – Attachment 49240 Details for
Bug 115566
beagled burning CPU ...
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
a patch which (at least partially) fixes this problem
03-bnc-115566-dont-poll-when-snarfing-inotify-events.patch (text/plain), 3.60 KB, created by
Jon Trowbridge
on 2005-09-08 16:45:41 UTC
(
hide
)
Description:
a patch which (at least partially) fixes this problem
Filename:
MIME Type:
Creator:
Jon Trowbridge
Created:
2005-09-08 16:45:41 UTC
Size:
3.60 KB
patch
obsolete
>? Util/ThreadPond.cs >? beagled/build-test >? beagled/outfile.beagled >? beagled/outfile.helper.1 >? beagled/outfile.helper.2 >? beagled/test-index >Index: Util/Inotify.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Util/Inotify.cs,v >retrieving revision 1.53 >diff -u -p -r1.53 Inotify.cs >--- Util/Inotify.cs 30 Aug 2005 18:58:56 -0000 1.53 >+++ Util/Inotify.cs 8 Sep 2005 16:40:06 -0000 >@@ -104,10 +104,12 @@ namespace Beagle.Util { > > [DllImport ("libinotifyglue")] > static extern unsafe void inotify_snarf_events (int fd, >- int timeout_ms, > out int nr, > out IntPtr buffer); > >+ [DllImport ("libinotifyglue")] >+ static extern void inotify_snarf_cancel (); >+ > ///////////////////////////////////////////////////////////////////////////////////// > > private class QueuedEvent { >@@ -455,6 +457,8 @@ namespace Beagle.Util { > running = false; > Monitor.Pulse (event_queue); > } >+ >+ inotify_snarf_cancel (); > } > > static unsafe void SnarfWorker () >@@ -474,7 +478,6 @@ namespace Beagle.Util { > > // Will block while waiting for events, but with a 1s timeout. > inotify_snarf_events (inotify_fd, >- 1000, > out nr, > out buffer); > >Index: glue/inotify-glue.c >=================================================================== >RCS file: /cvs/gnome/beagle/glue/inotify-glue.c,v >retrieving revision 1.25 >diff -u -p -r1.25 inotify-glue.c >--- glue/inotify-glue.c 19 Aug 2005 17:32:41 -0000 1.25 >+++ glue/inotify-glue.c 8 Sep 2005 16:40:06 -0000 >@@ -1,3 +1,5 @@ >+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ >+ > /* > * inotify-glue.c > * >@@ -49,6 +51,8 @@ static int max_user_instances = 8; > static int max_user_watches = 8192; > static int max_queued_events = 256; > >+static int snarf_cancellation_pipe [2]; >+ > /* Paranoid code to read an integer from a sysfs (well, any) file. */ > static void > read_int (const char *filename, int *var) >@@ -87,6 +91,9 @@ inotify_glue_init (void) > "enabled."); > } > >+ if (pipe (snarf_cancellation_pipe) == -1) >+ perror ("Can't create snarf_cancellation_pipe"); >+ > read_int (PROCFS_MAX_USER_DEVICES, &max_user_instances); > read_int (PROCFS_MAX_USER_WATCHES, &max_user_watches); > read_int (PROCFS_MAX_QUEUED_EVENTS, &max_queued_events); >@@ -125,6 +132,13 @@ inotify_glue_ignore (int fd, __u32 wd) > return ret; > } > >+void >+inotify_snarf_cancel () >+{ >+ write (snarf_cancellation_pipe [1], >+ &snarf_cancellation_pipe, 1); // write a convenient byte >+} >+ > > #define MAX_PENDING_COUNT 5 > #define PENDING_PAUSE_NANOSECONDS 2000000 >@@ -132,9 +146,9 @@ inotify_glue_ignore (int fd, __u32 wd) > #define PENDING_MARGINAL_COST(p) ((unsigned int) (1 << (p))) > > void >-inotify_snarf_events (int fd, int timeout_ms, int *nr, void **buffer_out) >+inotify_snarf_events (int fd, int *nr, void **buffer_out) > { >- struct pollfd pollfd = { fd, POLLIN | POLLPRI, 0 }; >+ struct pollfd pollfd [2] = { { fd, POLLIN | POLLPRI, 0 }, { snarf_cancellation_pipe [0], POLLIN, 0} }; > unsigned int prev_pending = 0, pending_count = 0; > static struct inotify_event *buffer = NULL; > static size_t buffer_size; >@@ -158,12 +172,17 @@ inotify_snarf_events (int fd, int timeou > *nr = 0; > > /* Wait for the file descriptor to be ready to read. */ >- ret = poll (&pollfd, 1, timeout_ms); >+ ret = poll (pollfd, 2, -1); > if (ret == -1) { > if (errno != EINTR) > perror ("poll"); > return; > } else if (ret == 0) >+ return; >+ >+ /* Return immediately if something happened on the >+ snarf cancellation pipe. */ >+ if (pollfd [1].revents != 0) > return; > > /* Reading events in groups significantly helps performance.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 115566
:
49019
| 49240