This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: The next release of win32-service is nigh
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
A long standing bug with win32-service may finally be fixed soon. Well, worked around anyway. There was a thread issue that caused a stop event to basically deadlock the service. Oh, it stopped the service, but in a long and ugly way, and the stop event handler wasn't being called.
Patrick Hurley submitted a patch/workaround where we create a separate Ruby thread internally and use that thread to do some polling. Its job is to make sure all other threads that have been spun up have returned when a stop signal is received, then sends a signal to indicate that its finally ready to stop.
It works, though it does require a little extra effort on the end user's part (it requires another state check), which I'm hoping to abstract away in a handy little wrapper.
This is not the final patch. Patrick has an even better one, but I'm going to wait until we separate the Daemon class from the Service class.