Bug 5993 - Slim::Utils::PluginManager->enabledPlugins() sometimes returns nothing
: Slim::Utils::PluginManager->enabledPlugins() sometimes returns nothing
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Plugins
: 7.0
: PC Windows XP
: P2 normal (vote)
: ---
Assigned To: Unassigned bug - please assign me!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-01 00:05 UTC by James Craig
Modified: 2007-11-07 06:55 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Craig 2007-11-01 00:05:16 UTC
First call of Slim::Utils::PluginManager->enabledPlugins() returns nothing. 
Second call returns expected results.

Here's some logging from Erlend's Dynamic Playlist plugin:
[21:36:36.4124] Plugins::DynamicPlayList::Plugin::initPlayLists (684) Searching for playlists
[21:36:36.4143] Plugins::DynamicPlayList::Plugin::initPlayLists (691) Enabled Plugins are:
[21:36:36.4155] Plugins::DynamicPlayList::Plugin::registerJiveMenu (1809) Creating Jive Menu
[21:36:40.0194] Plugins::DynamicPlayList::Plugin::initFilters (829) Searching for filters
[21:36:40.0230] Plugins::DynamicPlayList::Plugin::initPlayLists (684) Searching for playlists
[21:36:40.0250] Plugins::DynamicPlayList::Plugin::initPlayLists (691) Enabled Plugins are:Slim::Plugin::Rhapsody::Plugin Slim::Plugin::PreventStandby::PluginSlim::Plugin:: RSSNews::Plugin Slim::Plugin::Visualizer::Plugin Slim::Plugin::Snow::Plugin Slim::Plugin::RadioTime::Plugin Slim::Plugin::DateTime::Plugin Slim::Plugin::DigitalInput::Plugin Plugins::IRBlaster::Plugin Slim::Plugin::Live365::Plugin Slim::Plugin::LMA::Plugin Slim::Plugin::InfoBrowser::Plugin Slim::Plugin::Rha...
Comment 1 James Craig 2007-11-01 00:46:18 UTC
On further investigation it doesn't seem to be the first call which returns nothing, but I can't work out what the cause is. In Slim::Utils::PluginManager::_filterPlugins, sometimes the loop is never entered. 

It so happens that I can repeat this every time with the call in the Dynamic Playlist plugin, but from logging I can see that this is not the first time the function has been called.

However if I add a log message to print the keys of the $plugins hash before this loop, the function works every time.

Here's the output of some logging I added to the PluginManager class:
good results:
[07:42:45.8604] Slim::Utils::PluginManager::enabledPlugins (524) Slim::Utils::PluginManager
[07:42:45.8613] Slim::Utils::PluginManager::installedPlugins (445) here
[07:42:45.8625] Slim::Utils::PluginManager::_filterPlugins (453) Filtering plugins error for 0
[07:42:45.8677] Slim::Utils::PluginManager::_filterPlugins (455) HASH(0x58bdb84)
[07:42:45.8687] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::Rhapsody::Plugin,HASH(0x58c7ad4)
[07:42:45.8695] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::PreventStandby::Plugin,HASH(0x58b8644)
[07:42:45.8708] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::RSSNews::Plugin,HASH(0x58c71ec)
...trimmed...
[07:42:45.8986] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::SavePlaylist::Plugin,HASH(0x58c7e4c)
[07:42:45.8994] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::iTunes::Plugin,HASH(0x58bd980)
[07:42:45.9001] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::Favorites::Plugin,HASH(0x58bb318)
[07:42:45.9008] Slim::Utils::PluginManager::_filterPlugins (459) Slim::Plugin::RadioIO::Plugin,HASH(0x58c73cc)
[07:42:45.9015] Slim::Utils::PluginManager::_filterPlugins (467) checked 40 plugins

and then immediately afterwards, bad results:
[07:42:54.8429] Slim::Utils::PluginManager::enabledPlugins (524) Slim::Utils::PluginManager
[07:42:54.8438] Slim::Utils::PluginManager::installedPlugins (445) here
[07:42:54.8462] Slim::Utils::PluginManager::_filterPlugins (453) Filtering plugins error for 0
[07:42:54.8471] Slim::Utils::PluginManager::_filterPlugins (455) HASH(0x58bdb84)
[07:42:54.8479] Slim::Utils::PluginManager::_filterPlugins (467) checked 0 plugins

Very puzzling.
Comment 2 James Craig 2007-11-01 00:53:19 UTC
Could it have something to do with this: http://taint.org/2006/04/03/121837a.html ?
There is a single iterator for each hash, shared by all “each”, “keys”, and “values” function calls in the program
Comment 3 Michael Herger 2007-11-01 04:55:24 UTC
I've seen this too. I thought it was only the very first time it was called. Do you see it more than this?
Comment 4 James Craig 2007-11-01 05:46:43 UTC
Hmmm I don't think so because you can see from the log it wasn't the first call of enabledPlugins() server-wide.

It does seem like it's the first call from a specific plugin that encounters it, but I can't immediately think of any reason why that would be the case (other than this iterator issue)
Comment 5 Andy Grundman 2007-11-07 06:55:49 UTC
Fixed in change 14455.