lelotto85, the way I read this MPM-prefork doc snippet is that prefork is the appropriate multiprocessing mode if you want to run an Apache module that is itself not thread safe, stuff like *cough*mod_php*cough*. These modules fail if they are entered by multiple threads at the same time, e.g. because they use module-global variables, so Apache plays it safe with MPM-prefork and simply forks a new process for each connection handler. That doesn't mean that modules that are in fact able to use threads can't use them in the context of this process, think (as I said that's speculation because I haven't tried) it's rather the opposite: if Apache doesn't manage its own threading, you're least likely to screw it up when you create your own threads. May be worth trying.

That said, are you sure you need threads in your CGI? Depending on what other content or even other sites your Apache serves MPM-prefork can perform worse than other modules, especially on slow forkers like Solaris or Windows. Frameworks like Coro or POE could save you some headaches (although the latter may bring its own performance problems by being rather fat) by using cooperative multitasking that lets you have virtual threads without real multiprocessing. A sensibly loaded web server will make use of multiple CPUs anyway by using them to handle distinct connections.


In reply to Re^4: cgi thread creation segfault by mbethke
in thread cgi thread creation segfault by lelotto85

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.