public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Timothy Miller <miller@techsource.com>
To: Krzysztof Halasa <khc@pm.waw.pl>
Cc: David Schwartz <davids@webmaster.com>, linux-kernel@vger.kernel.org
Subject: Re: select for UNIX sockets?
Date: Tue, 10 Jun 2003 09:34:54 -0400	[thread overview]
Message-ID: <3EE5DE7E.4090800@techsource.com> (raw)
In-Reply-To: m3isredh4e.fsf@defiant.pm.waw.pl



Krzysztof Halasa wrote:
> "David Schwartz" <davids@webmaster.com> writes:

>>	The kernel does not remember that you got a write hit on 'select'
>>and use
>>it to somehow ensure that your next 'write' doesn't block. A 'write' hit
>>from 'select' is just a hint and not an absolute guarantee that whatever
>>'write' operation you happen to choose to do won't block.
> 
> 
> A "write" hit from select() is not a hit - it's exactly nothing and this
> is the problem.
> Have you at least looked at the actual code? unix_dgram_sendmsg() and
> datagram_poll()?


I think the issue here is not what it means when select() returns but 
what it means when it DOESN'T return (well, blocks).

In my understanding, one of select()'s purposes is to keep processes 
from having to busy-wait, burning CPU for nothing.  Your guarantee with 
select() is that if it blocks, then the write target(s) definately 
cannot accept data.  The inverse is not true, although the inverse is 
very likely:  if select() does not block, then it's extremely likely 
that the target can accept SOME data.  But it it certainly can't accept 
ALL data you want to give it if you want to give it a lot of data.

If you were to use blocking writes, and you sent too much data, then you 
would block.  If you were to use non-blocking writes, then the socket 
would take as much data as it could, then return from write() with an 
indication of how much data actually got sent.  Then you call select() 
again so as to wait for your next opportunity to send some more of your 
data.

It may be that some operating systems have large or expandable queues 
for UNIX sockets.  As a result, you have been able to send a lot of data 
with a blocking write without it blocking.  I can see how it would be an 
advantage to function that way, up to a certain point, after which you 
start eating too much memory for your queue.  However, what you have 
experienced is not universally guaranteed behavior.  What Linux does is 
canonically correct; it's just a variant that you're not used to.  If 
you were to change your approach to fit the standard, then you would get 
more consistent behavior across multiple platforms.

Up to this point, I believe you have been riding on luck, not guaranteed 
behavior.


  reply	other threads:[~2003-06-10 13:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-06 12:20 select for UNIX sockets? MarKol
2003-06-07  0:14 ` David Schwartz
2003-06-08  0:04   ` Krzysztof Halasa
2003-06-09  3:11     ` David Schwartz
2003-06-09 17:18       ` Krzysztof Halasa
2003-06-09 17:55         ` David Schwartz
2003-06-09 22:24           ` Krzysztof Halasa
2003-06-10 13:34             ` Timothy Miller [this message]
2003-06-10 13:52               ` Richard B. Johnson
2003-06-10 14:21               ` Krzysztof Halasa
2003-06-10 19:04                 ` Jesse Pollard
2003-06-11 21:55                   ` Krzysztof Halasa
2003-06-11 22:50                     ` David Schwartz
2003-06-11 12:51                 ` Edgar Toernig
2003-06-10 21:40             ` David Schwartz
2003-06-11 22:04               ` Krzysztof Halasa
2003-06-09 23:45         ` James Stevenson
2003-06-08  4:15   ` Chris Friesen
2003-06-09  3:05     ` David Schwartz
2003-06-09 16:46   ` MarKol
2003-06-09 17:05     ` David Schwartz
  -- strict thread matches above, loose matches on Subject: below --
2003-06-04 12:19 Petr Vandrovec
2003-06-06  0:28 ` Valdis.Kletnieks
2003-06-06  0:38   ` Petr Vandrovec
2003-06-03  0:08 Krzysztof Halasa
2003-06-03 14:51 ` Alan Cox
2003-06-04 23:27   ` Krzysztof Halasa
2003-06-05 13:17     ` Krzysztof Halasa
2003-06-04 11:55 ` Jesse Pollard
2003-06-04 12:42   ` Krzysztof Halasa

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=3EE5DE7E.4090800@techsource.com \
    --to=miller@techsource.com \
    --cc=davids@webmaster.com \
    --cc=khc@pm.waw.pl \
    --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