Re: lock on accept



On 30 May 2007 14:16:20 -0700 David Schwartz <davids@xxxxxxxxxxxxx> wrote:

| The best way would be to write a program that blocks a few threads on
| 'accept' and then makes a connection to itself. If more than one
| thread unblocks but all but one get an error, then you have a non-
| ideal situation. If more than one thread actually succeeds, then you
| have a fatal situation.

You mean like 2 or more threads wake up from accept() with the same
descriptor given to each for the one socket that is connected?


| That is my recollection. Checking the apache lists and code comments
| might be instructive, I believe they've dealt with this issue
| extensively. (Note that they mainly dealt with multiple processes that
| had all inherited the same listening socket.)

Hopefully, any fix applies properly for both processes and threads.


| Also do not be confused. There is accept serialization still going on
| but it's for a completely different reason. Apache now allows you to
| listen on more than one port, which means more than one listening
| socket. This means Apache has to use 'select' and then call 'accept'.
| The serialization is to prevent all the threads/processes from waking
| from 'select', which the OS must do because it cannot be sure any of
| them are actually going to call 'accept'.

Maybe we need some kind of multi-socket accept() or container socket.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2007-05-31-0643@xxxxxxxx |
|------------------------------------/-------------------------------------|
.



Relevant Pages

  • Re: !EventConnect Problem
    ... poll time of 500mS we get a break in communication approx once a day, ... The socket is not in a listening state. ... There's a problem with the connection address, ...
    (microsoft.public.windowsce.app.development)
  • Re: accept 1000 or more incoming conection
    ... The listen function places a socket a state where it is listening for ... SOCKET s, ... Now i have developed a client that Makes 500 connection to a server at ...
    (comp.programming.threads)
  • Re: Linux 2.4.27 SECURITY BUG - TCP Local (probable Remote) Denial of Service
    ... > you will see that there are occurrences where a connection ... > apache, on an unmoded Linux box ... It might be the same with mysql. ... socket once it does not need it anymore. ...
    (Linux-Kernel)
  • Re: Socket and cycle problem
    ... listening this port countinously. ... So I need make some loop to print data from 3883 port permanent. ... the data it receives from each connection after the remote side drops ... If you were to use the socket module, then it would look something like this: ...
    (comp.lang.python)
  • Re: lock on accept
    ... | 'accept' and then makes a connection to itself. ... descriptor given to each for the one socket that is connected? ... The only reason the Apache folks encountered it is because they had ... so platforms that support threading should ...
    (comp.unix.programmer)