From: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
To: dyp@perchine.com (Denis Perchine)
Cc: linux-kernel@vger.kernel.org
Subject: Re: Problems with kernel-2.2.19-6.2.7 from RH update for 6.2
Date: Wed, 22 Aug 2001 04:53:24 +0400 (MSD) [thread overview]
Message-ID: <200108220053.EAA01602@mops.inr.ac.ru> (raw)
In-Reply-To: <20010820155450.777C91FD74@mx.webmailstation.com> from "Denis Perchine" at Aug 21, 1 01:52:04 am
Hello!
> > BTW why do you use funny getsockopt instead of canonical non-blocking
> > connect?
>
> Hmmm... If I know what canonical non-blocking connect is, I would use it =
> I=20
> think...
connect() is used to complete asynchronously started connect.
While connection is not complete connect() returns EALREADY.
When connection is established, it succeeds. If connection fails,
it returns an error (the same, which you get with getsockopt()).
So, right way is to repeat connect() after poll() returned POLLOUT,
it will either complete connection or return an error to you.
Actually, this classic interface is very ugly. Seems, it is the only place,
where O_NONBLOCK is used not to do something nonblocking, but to start
an asynchronous operation. And all these terrible unique error codes:
EINPROGRESS, EALREADY suck. Thank to bsd people, who preferred ugly
hacks instead of developing some AIO interface. :-)
It is so ugly (it is the only place where kernel has to maintain history
of user syscalls in addition to tcp state), that it is even offending
that people do not use it; it means that it simply pollutes kernel. :-)
> the combination which works. Actually thttpd also uses this (if I am not=20
> mistaken).
Where? httpd does not connect().
If they do this after accept(), it is really silly. Pure useless syscall.
> The problem here is that I need to tune timeout for: each connection, and=
> for=20
> connect, and read/write separately. If you could give me an advise how to=
> do=20
> this more effective, I would be really glad.
I see. If tuning is goal, it is right way. Amount of syscalls
is the same as with alarm, but logic is cleaner.
Though, with read/write SO_RCVTIMEO/SO_SNDTIMEO is preferred.
Unfortunately, linux-2.2 seems to be the only OS not implemented this.
[ I am not sure about Solaris though. ]
In linux-2.4 they work for connect/accept too: SO_SNDTIMEO for
connect, SO_RCVTIMEO for accept.
Alexey
next prev parent reply other threads:[~2001-08-22 17:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-19 18:01 Denis Perchine
2001-08-20 2:11 ` Alexey Kuznetsov
2001-08-20 18:52 ` Denis Perchine
2001-08-22 0:53 ` Alexey Kuznetsov [this message]
2001-08-23 4:32 ` Denis Perchine
2001-08-23 16:29 ` kuznet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200108220053.EAA01602@mops.inr.ac.ru \
--to=kuznet@ms2.inr.ac.ru \
--cc=dyp@perchine.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®