guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Bindings for ‘sendfile’


From: Ludovic Courtès
Subject: Re: [PATCH] Bindings for ‘sendfile’
Date: Tue, 09 Apr 2013 17:02:03 +0200
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux)

Hi!

Thien-Thi Nguyen <address@hidden> skribis:

> () address@hidden (Ludovic Courtès)
> () Sun, 07 Apr 2013 21:53:26 +0200
>
>    +In other cases, the libc function may send fewer bytes than
>    address@hidden instance because @var{out} is a slow or limited
>    +device, such as a pipe.  When that happens, Guile's @code{sendfile}
>    +automatically retries until exactly @var{count} bytes were sent or an
>    +error occurs.
>
> A short write is an opportunity for the caller to Do Something Else
> (i.e., go asynchronous).  I think that is more useful than internalizing
> the looping.  To accomodate both usage patterns, you could leave the
> low-level proc as-is (as-was :-D) and provide another proc that loops.

Well, I hesitated a lot.  My initial inclination was to do what you say,
and let users handle the looping.

After a long discussion on IRC was Mark, I was mostly convinced that
leaving that to users is questionable.

First, because one obviously expects the procedure to send the file, not
just part of it.  Second, those who did not forget to implement the loop
can easily get it wrong.  Third, if you really want to interleave I/O
and computation, you probably don’t want to use sendfile(2) in the first
place.  Fourth, ‘write’, ‘put-bytevector’, etc. also hide short writes.

My 4¢,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]