* [Bluez-devel] Possible infinite loop in inotify code
@ 2007-10-04 15:27 Bastien Nocera
2007-10-04 16:02 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Bastien Nocera @ 2007-10-04 15:27 UTC (permalink / raw)
To: BlueZ Hackers
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
Heya,
Uli mentioned a possible infinite loop in some circumstances:
https://bugzilla.redhat.com/show_bug.cgi?id=235307
Although I wasn't able to reproduce the bug, the attached patch looks
technically correct.
Cheers
--
Bastien Nocera <hadess@hadess.net>
[-- Attachment #2: bluez-utils-better-inotify-error.patch --]
[-- Type: text/x-patch, Size: 1171 bytes --]
? .deps
? .libs
? Makefile
? Makefile.in
? bluez-utils-better-inotify-error.patch
? test_textfile
Index: notify-inotify.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/notify-inotify.c,v
retrieving revision 1.8
diff -u -p -r1.8 notify-inotify.c
--- notify-inotify.c 16 Feb 2007 20:18:37 -0000 1.8
+++ notify-inotify.c 4 Oct 2007 15:23:55 -0000
@@ -60,14 +60,21 @@ static gboolean io_event(GIOChannel *cha
memset(buf, 0, sizeof(buf));
err = g_io_channel_read(chan, (gchar *) buf, sizeof(buf) - 1, &len);
- if (err == G_IO_ERROR_AGAIN)
+ if (err == G_IO_STATUS_AGAIN) {
return TRUE;
+ } else if (err != G_IO_STATUS_NORMAL) {
+ error("Error reading from channel: No error given");
+ return FALSE;
+ }
while (len >= sizeof(struct inotify_event)) {
struct inotify_event *evt = (struct inotify_event *) ptr;
- if (evt->wd != wd || !callback)
+ if (evt->wd != wd || !callback) {
+ len -= sizeof(struct inotify_event) + evt->len;
+ ptr += sizeof(struct inotify_event) + evt->len;
continue;
+ }
if (evt->mask & (IN_CREATE | IN_MOVED_TO))
callback(NOTIFY_CREATE, evt->name, NULL);
[-- Attachment #3: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Bluez-devel] Possible infinite loop in inotify code
2007-10-04 15:27 [Bluez-devel] Possible infinite loop in inotify code Bastien Nocera
@ 2007-10-04 16:02 ` Marcel Holtmann
2007-10-04 16:09 ` Bastien Nocera
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2007-10-04 16:02 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> Uli mentioned a possible infinite loop in some circumstances:
> https://bugzilla.redhat.com/show_bug.cgi?id=235307
>
> Although I wasn't able to reproduce the bug, the attached patch looks
> technically correct.
I reworked the patch a little bit and applied it. The G_IO_STATUS_AGAIN
and G_IO_ERROR_AGAIN are not guaranteed to be the same.
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] Possible infinite loop in inotify code
2007-10-04 16:02 ` Marcel Holtmann
@ 2007-10-04 16:09 ` Bastien Nocera
0 siblings, 0 replies; 3+ messages in thread
From: Bastien Nocera @ 2007-10-04 16:09 UTC (permalink / raw)
To: BlueZ development
On Thu, 2007-10-04 at 18:02 +0200, Marcel Holtmann wrote:
> Hi Bastien,
>
> > Uli mentioned a possible infinite loop in some circumstances:
> > https://bugzilla.redhat.com/show_bug.cgi?id=235307
> >
> > Although I wasn't able to reproduce the bug, the attached patch looks
> > technically correct.
>
> I reworked the patch a little bit and applied it. The G_IO_STATUS_AGAIN
> and G_IO_ERROR_AGAIN are not guaranteed to be the same.
My mistake, I made the first patch using g_io_channel_read_chars instead
of the deprecated g_io_channel_read and changed the code accordingly
(including possible retvals), but then remembered eglib. I guess I
didn't completely revert those changes.
Cheers
--
Bastien Nocera <hadess@hadess.net>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-04 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-04 15:27 [Bluez-devel] Possible infinite loop in inotify code Bastien Nocera
2007-10-04 16:02 ` Marcel Holtmann
2007-10-04 16:09 ` Bastien Nocera
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox