From e0b5cb8dce7e3a1c2203c5e7a83d0391a46845ef Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 6 Dec 2007 20:41:55 +0100 Subject: [PATCH] fix endless loop in storage-addon This fixes a endless loop if you attach e.g. a USB floppy device which already contains a floppy media (because of the initial media_status). The result is that the media in the device get never detected until the state change again (remove/readd the media to the device). IMO this could theoretically also happen on other devices which already contains a media when attached. --- hald/linux/addons/addon-storage.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hald/linux/addons/addon-storage.c b/hald/linux/addons/addon-storage.c index a58b8aa..42385fc 100644 --- a/hald/linux/addons/addon-storage.c +++ b/hald/linux/addons/addon-storage.c @@ -473,6 +473,14 @@ poll_for_media (gpointer user_data) } } + /* set correct state on startup, this avoid endless loops if there was a media in the device on startup */ + if (media_status == MEDIA_STATUS_UNKNOWN) { + if (got_media) + media_status = MEDIA_STATUS_NO_MEDIA; + else + media_status = MEDIA_STATUS_GOT_MEDIA; + } + switch (media_status) { case MEDIA_STATUS_GOT_MEDIA: if (!got_media) { -- 1.5.3.7