[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    Re: [apache-modules] select()ing client sockets (was: Re: Thread)
From:       Christian Parpart <cparpart () surakware ! net>
Date:       2004-01-13 19:53:04
Message-ID: 200401132053.09029.cparpart () surakware ! net
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 13 January 2004 8:26 pm, rm@fabula.de wrote:
> On Tue, Jan 13, 2004 at 06:25:57PM +0100, Christian Parpart wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > On Tuesday 13 January 2004 6:02 pm, Marco Spinetti wrote:
> > > No,
> > > 
> > > I'm starting threads in child process (inside handler function) not
> > > during reading of configuration data.
> > > 
> > > Reading your email it seems that using pthreads inside child process in
> > > apache 1.3.x gives strange results and it will not work as expected,
> > > while using apache 2 all is ok.
> > > 
> > > Is it true?
> > 
> > it is not (at all).
> 
> Are you talking about v1.3.x or 2.x.x???

2.0.x

> > I believe this, because I have developed a module that had to watch for
> > I/O events on 2 sockets (web client and backend server). This was done in
> > a backgroupd thread, so that I could do usual work in the main handler
> > process. Unfortunately, my error log was flooding me with thouthends of
> > segfault messages (very often requested module), and after having removed
> > any thread connection in this module, my segfaults has been reduced to a
> > very more acceptable minimum.
> 
> Sorry, without any offence, but this doesn't say anything about the
> possibility of threading in Apache per se, or? 

no, it doesn't, just as you say. but this is *my* experience, as well as I 
must experience, that apache doesn't like C++ exceptions at all, too :(
Again, this is *my* experience, nothing definite.

> I'm not a thread advocate at 
> all and try to avoid them but there are a lot of place one can mess up
> (hmm, did you try to 'select' on the _client_ filehandle? That's probably
> not a good idea - that's where apache comes in ...).

Unfortunately I had to, and still have to.
Because I *have* to react as fast as possible on client aborts. (think about a 
message streaming server, that has to logout the user as soon as the client 
aborted the connection to apache).
The second file descriptor is the socket connection to the server, that I have 
to watch on sending events and server side connection closes (or server side 
crashes, however).
Both are currently select()'ed.

See this URL (and STRG-F for "select"):
http://cvs.surakware.net/viewcvs.cgi/trunk/src/clients/mod_yacs/TChatStreamer.cpp?rev=HEAD&root=YaCS&content-type=text/vnd.viewcvs-markup


> > > What is the right and real answer?
> > 
> > The right thing I believe, is, if you'r coding an apache module, you
> > should try to design it in a flat model, that is, without any threads.
> > For listening for I/O events for example do a select/poll/epoll or even
> > use (that still not yet understood how to use easily) apr_poll API by
> > apache.
> 
> Yes, apr_poll seems to be the 'right' way if one wants to use threads.

is this an explicit if? I mean, I did not yet got rid of apr_poll, except 
knowing of it;
shall I use apr_poll over select/poll/epoll, too? Even if I've eliminated any 
multi threads in the apache module?

> HTH Ralf Mattes

Greets,
Christian Parpart.

- -- 
 20:41:50 up 7 days,  7:31,  3 users,  load average: 0.85, 0.88, 0.73
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFABEyjPpa2GmDVhK0RArRGAJ0Ru71z+mQzwC6sf1mCU24agA7R8ACgg9Pf
dJlhxDPZZfEwngvwmn+xDM0=
=4uVU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic