Err, no :) It's a bit more complicated (for good reason).
Indeed the HTTPS (original, unposted) server is single-threaded and embarassingly multiplexed (accept only). It has a reference to a "Dispatcher" object - also in the same thread.
The Dispatcher object when instantiated creates two Thread::Queue::Any objects. It does (obviously) import Threads, but is passed to the HTTPS server's package in such a way as that package does *not* import Threads.
After creating the queue objects, Dispatcher's constructor creates a new thread, passing it the two queue objects, wherein the new thread enters a loop dequeuing requests from one queue, and enqueuing responses to the other queue.
The HTTPS daemon accesses the Dispatcher through its methods: dispatchRequest, pendingReponses, retrieveResponse. Those methods interact *only* with the two queue objects (always in the main thread in which the HTTPS daemon resides).
Why?
IO::Socket::SSL objects break badly when Threads is imported in the same scope (and "no threads" doesn't help ;)
That whole mess was devised so that the work implied by HTTPS requests could be farmed out to a number of "worker" threads from the Dispatcher, without ever letting the HTTPS server's package be exposed to the Threads module.
All of that was quite successful. Thelonius and yourself are quite right to suggest that the SSL handshakes were being missed while previous (blocking) requests were being serviced. The code in the OP was almost there, however the state-machine was wrong because it did not fully emulate the work done by IO::Socket::SSL's accept() method in a multiplexing fashion.
The server code Thelonius posted resolved that issue.
-David.
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.