Re: accept() improvements for rt signals

From: Stephen C. Tweedie (sct@redhat.com)
Date: Tue Feb 22 2000 - 06:02:29 EST


Hi,

On Sun, 20 Feb 2000 16:48:04 +0200 (EET), Julian Anastasov
<uli@linux.tu-varna.acad.bg> said:

> I have played these days with accept() and sigwaitinfo().
> It seems that for single threaded server we have to:

> 1. setup listening socket: O_ASYNC|O_NONBLOCK, SETOWN my_pid,
> signals (SIGIO, SIGRTMIN...), etc.

> In the loop:

> 2. accept() the connection
> 3. fcntl(connected_socket,F_SETFL,O_NONBLOCK|O_ASYNC|O_RDWR)
> 4. fcntl(connected_socket,F_SETSIG,sig)
> 5. fcntl(connected_socket,F_SETOWN,again_my_pid)
> 6. read(connected_socket...), sigwaitinfo()

> It is possible between points 2 and 5 the data for
> the connected socket to arrive. So, I had to put an extra
> read() after F_SETOWN to detect this condition.

Yes. I'm looking at adding a F_SETFAST() fcntl, which will do a
F_SETFL, F_SETSIG and F_SETOWN at once on the socket, and return a
poll struct indicating any outstanding IO on the socket so that you
don't have to do a speculative read() to detect data arrived before you
made the fcntl call.

> My proposal: is it possible to add SO_INHERITOWN or other
> socket/file (F_COPYOWN) option suitable for listening sockets
> with the main goal to let sys_accept() to copy the fd owner after
> get_fd(2.2.x) or sock_map_fd(2.3.x) in net/socket.c.

Definitely a good idea --- a lot of other O/Ses already have something
like that. We can inherit socket options the same way, of course, which
will be useful for a lot of services.

> I haven't made a patch yet. I need more opinions
> about this problem. May be I'm wrong? Are there any other
> things that can be inherited from the listening socket
> using the new option or only the f_owner is enough?

TCP_CORK, linger options, all sorts of others.

--Stephen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:30 EST