Well, after thinking about it quite a bit and exploring some other options I have decided that doing a
fork from a mod_perl handler is not really that bad. I took some time and made the child process more robust. What I found out was that
forking a child really didn't slow the call down a noticeable difference. Not only that but the advantage of having the heartbeat on a function call is so great that the 0.001ths of a second slow-down I'm seeing is quite acceptable.
So for those interested this is how it works.
The SOAP::Lite client makes a standard RPC call. When that call hits the server side (Apache mod_perl) endpoint code a child process is forked and intermittently sends the parent process SIGUSR2. The parent process has a handler for that signal, of course, and even reimplements
sleep in such a way that it is not interuptable by SIGUSR2. The SIGUSR2 handler then prints to STDOUT the proper returning HTTP headers with a content type of multipart/x-mixed-replace denoting a server push. This push will then keep the connection back to the client from timing out. Once the real processing has taken place in the parent, the parent
kills the child nicely and writes back the response. The final response is captured in SOAP::MIMEParser::decode. But SOAP::MIMEParser::decode doesn't know about multipart/x-mixed-replace, so I had to rewrite/override that function and add about 10 lines of code... no big deal. After fixing up the response from SOAP::MIMEParser::decode everything acts as normal.
Well that's it. That is how I implemented a heartbeat for my SOAP::Lite long running functions.
Cheers!
--habit
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.