Mikhail Gusarov wrote:
> PS> Do a lot of systems actually block there instead of having write()
> PS> return size/2?
> 
> They ALL do.

Hmm. I don't think they should.

--8<-- Linux write(2)
DESCRIPTION
       write() writes up to count bytes from the buffer pointed buf to the
       file referred to by the file descriptor fd.

       The number of bytes written may be less than count if, for example,
       there is insufficient space on the underlying physical medium, or the
       RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)), or the
       call was interrupted by a signal handler after having written less than
       count bytes.  (See also pipe(7).)

...


RETURN VALUE
       On success, the number of bytes written is returned (zero indicates
       nothing was written). On error, -1 is returned, and errno is set
       appropriately.
-->8--

So short writes must be handled anyway.


> Why a kernel can't block on read/write on blocking socket?

Sorry, what?


> Why reading From socket can't block if there is not enough data
> available on the other side yet?

Ok, for reading nbio solves the problem when an application wants to
use both a really problematic SSH fd and another very unproblematic
high throughput fd. Even though SSH has a nice packetized protocol if
there's congestion holding up incoming data, that would indeed affect
also the communicion on the other fd.

Chances are they are related anyway, or no?


I can certainly understand the motivation for nbio in a transfer
intense program, such as curl. I'm not so sure for libssh2. It
continues to cause a fair amount of problems.


> Why writing to socket can't block if there is no buffer space
> available in network driver?

If there is no space at all select() should not indicate writable. If
there is little space, write() should return short. If there was
space, but then that changed into no space, isn't select() just plain
broken?

If select() returns readable there is data, why would there suddenly
not be data anymore?

If select() returns writable there is room for writing data, why
would there suddenly not be room for data (being written to the
kernel) anymore?


//Peter

Attachment: pgpTA3WQT2o3y.pgp
Description: PGP signature

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to