miyagawa / Starman

Starman is a high-performance preforking Perl PSGI web server
http://search.cpan.org/dist/Starman
Other
287 stars 84 forks source link

Fixed concurrent modification bug in hash iterator for net_server_args #113

Closed kriegfrj closed 9 years ago

kriegfrj commented 9 years ago

I was alerted to this by warnings on my console during testing.

The code in Plack::Handler::Starman that implemented #111 was attempting to modify the $self hash (adding the net_server_args entry) while iterating over it using each. This causes the iterator to become undefined because the insertion of a new element can change the iterator order. Fixed by accumulating all the options in a sub-hash first, and then adding the sub-hash (if non-empty) when the iteration is complete.

miyagawa commented 9 years ago

Good catch!

kriegfrj commented 9 years ago

At least all my messing around in #112 bore some fruit. :wink: