[Win32utils-devel] win32-service patch

Patrick Hurley phurley at gmail.com
Mon Jun 19 12:30:48 EDT 2006

Attached is a patch and my service.c if there is any difficulty
applying the patch. I did the following:

1. Created a ruby thread (Ruby_Service_Ctrl), that polls against a
simple integer value (protected by a critical section). I was worried
this would be "expensive"; however, I found the rb_thread_polling
method and it seems to work well.

2. When an event occurs in Service_Ctrl it sets the flag value.

3. If Ruby_Service_Ctrl finds an entry in the call back hash it
invokes it (in its own thread) and goes back to polling

4. On a SERVICE_CONTROL_STOP the Ruby_Service_Ctrl, processes normally
and then begins to exit, but it first waits for all previously spun
threads to return.

5. Service_Ctrl on a stop waits for Ruby_Service_Ctrl to indicate that
all threads are stopped before stopping the service (it continues to
update service status politley).

That's it -- in my tests it works perfectly. If I made any fax paus in
my patch creation or summary please let me know.

Thanks again
-------------- next part --------------
A non-text attachment was scrubbed...
Name: green_thread.patch
Type: application/octet-stream
Size: 4627 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060619/8cb30214/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: service.c
Type: application/octet-stream
Size: 57877 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060619/8cb30214/attachment-0003.obj 

More information about the win32utils-devel mailing list