Patches: Browse | Submit New | Admin

[#16627] Replace inefficient busy wait loop with UDP/IP loopback socket.

Date:
2007-12-27 02:13
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
win32-service
State:
Open
Summary:
Replace inefficient busy wait loop with UDP/IP loopback socket.

Detailed description
Here are some patches for win32-service which eliminate the messy busy loop that polls the hStopEvent with a zero timeout.
Instead of using a Windows event, these patches create a UDP/IP socket bound to the loopback interface which can be
used in ruby's green  threads event loop.  I believe this is a much cleaner and more efficient mechanism than the WIndows
event flag since it allows the ruby thread to block until there's really a control event from the WIndows service
manager.

I also include a hCtrlEvent event flag which can be used by ruby win32 services which must wait for control events.
This event handle is accessible via the daemon.event_handle method.  Note that the hCtrlEvent is not used by the daemon.c
logic, it's merely an event which can be used by the Daemon subclass.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2014-01-10 15:45
Sender: Daniel Berger

We converted the code to pure Ruby using FFI not too long ago,
but we did not use this implementation. However, I'm still open
to the idea if you feel it's still relevant for Ruby 1.9
or later.
Date: 2008-11-10 22:34
Sender: Daniel Berger

We've been looking at this implementation again, and Park has
implemented a version in pure Ruby.

The downside, at the moment, is that there's a socket bug in
the one-click that would make this problematic.

Regards,

Dan
Date: 2008-02-16 04:54
Sender: Daniel Berger

I haven't yet had a chance to seriously review this but I definitely
haven't forgotten it!

Thanks,

Dan

Attached Files:

Name Description Download
win32-service-0.6.0.diff Patches to eliminate busy loop. Download

Changes:

Field Old Value Date By
File Added3014: win32-service-0.6.0.diff2007-12-27 02:13None