Re: [PATCH 4/8] strbuf: add strbuf_read_once to read without blocking

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

 



On Mon, Dec 14, 2015 at 2:37 PM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> The new call will read from a file descriptor into a strbuf once. The
> underlying call xread_nonblock is meant to execute without blocking if
> the file descriptor is set to O_NONBLOCK. It is a bug to call
> strbuf_read_once on a file descriptor which would block.
>
> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
> ---
> diff --git a/strbuf.h b/strbuf.h
> @@ -367,6 +367,14 @@ extern size_t strbuf_fread(struct strbuf *, size_t, FILE *);
>  extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint);
>
>  /**
> + * Returns the number of new bytes appended to the sb.
> + * Negative return value signals there was an error returned from
> + * underlying read(2), in which case the caller should check errno.
> + * e.g. errno == EAGAIN when the read may have blocked.
> + */
> +extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);

strbuf_read_once() is a rather opaque name; without reading the
documentation, it's difficult to figure out what it means. I wonder if
strbuf_read_nonblock() or something would be clearer?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]