Kevin,

   If you are using a CGI script to start a perl thread, then it is
highly likely apache is timing out (the CGI hosting) your thread. 
(Apache threads should block on an executed CGI until it returns, or
apache times it out, whichever occurs first.)

   First of all, AFAIK, fork() is not an option on Win32 as it is
emulated using multiple perl interpreters in a process (e.g. ithreads).
 See http://perldoc.perl.org/perlport.html and
http://perldoc.perl.org/perlfork.html regarding this.

   (Note that if you were running on a platform with native fork(), you
would still need to isolate STDIN, STDOUT, and STDERR pipes of the
child process to truely daemonize the child process and allow the
parent apache thread to return.)

   Additionally, if your apache is configured to run multiple servers
(i.e. StartServers, MinSpareServers, and/or MaxSpareServers greater
than 1), then this thread "data server" you are trying to create will
need to exist isolated as a separate instance in each apache child
process.  This may or may not be an issue for what you are trying to do
with your thread "server".

   What is the purpose of using a long-running thread?  Just to provide
access to read-only data instead of reading it from a file every time?

You may wish to re-approach the problem using a data server independent
from both apache and perl.  I recommend you check out
http://www.danga.com/memcached/ as it's fast, reliable, fairly easy to
set up, and will persist data between *all* threads and processes
without any trickery.  There is also a lightweight perl API to use it,
which implements the Cache::Cache interface:
http://search.cpan.org/~bradfitz/Cache-Memcached-1.18/

Hope this helps a bit.

Regards,
Eric

--- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> I am trying to write a utility that contains a server which spins up
> in
> a cgi script.  I am using a thread (ithreads), do a check to see if
> it
> is running, and the start the server.  I have the thread creation in
> a
> module.  I am running in Win32, using an apache server, all
> relatively
> latest and greatest of evreything.
> 
> So, my server dies after some time of successful operation.  Is this
> due to Apache limiting how long a process can run?  I am considering
> a
> fork/exec (daemon-style), but would prefer not, as this poses other
> problems.  If I do use fork, is the only way to communicate to it
> through IPCs (message queue, socket, etc?)?
> 
> Also, I don't know how to handle static data in perl.  I have a
> function in my module that looks up data out of a file.  How can I
> look
> it up once, and keep it in memory thereafter?  Make it shared, and
> part
> of my ever-running thread, or is there another way?  Every time I
> enter
> into my module for a function call, this data gets read from a file.
> 
> Thanks in advance,
> 
> -Kevin
> 
> 

Reply via email to