All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Marek Behún" <kabel@kernel.org>
Cc: u-boot@lists.denx.de, pali@kernel.org,
	"Marek Behún" <marek.behun@nic.cz>
Subject: Re: [PATCH u-boot-marvell 12/14] tools: kwboot: Handle EINTR in kwboot_tty_recv()
Date: Wed, 26 Jan 2022 16:41:56 +0100	[thread overview]
Message-ID: <7d737949-811a-7018-2c9c-a81e588a9c64@denx.de> (raw)
In-Reply-To: <20220125171313.14498-13-kabel@kernel.org>

On 1/25/22 18:13, Marek Behún wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> The select() and read() syscalls may be interrupted. Handle EINTR and
> retry them.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   tools/kwboot.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index 8b748f0fdd..fca1c73c55 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -409,15 +409,19 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)
>   
>   	do {
>   		nfds = select(fd + 1, &rfds, NULL, NULL, &tv);
> -		if (nfds < 0)
> +		if (nfds < 0 && errno == EINTR)
> +			continue;
> +		else if (nfds < 0)
>   			goto out;
> -		if (!nfds) {
> +		else if (!nfds) {
>   			errno = ETIMEDOUT;
>   			goto out;
>   		}
>   
>   		n = read(fd, buf, len);
> -		if (n <= 0)
> +		if (n < 0 && errno == EINTR)
> +			continue;
> +		else if (n <= 0)
>   			goto out;
>   
>   		buf = (char *)buf + n;

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

  reply	other threads:[~2022-01-26 15:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 17:12 [PATCH u-boot-marvell 00/14] Another set of kwboot improvements Marek Behún
2022-01-25 17:13 ` [PATCH u-boot-marvell 01/14] tools: kwboot: Increase blk_rsp_timeo to 2s Marek Behún
2022-01-26 15:34   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 02/14] tools: kwboot: Wait blk_rsp_timeo when flushing Marek Behún
2022-01-26 15:34   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 03/14] tools: kwboot: Improve retrying logic for incomplete xmodem packets Marek Behún
2022-01-26 15:34   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 04/14] tools: kwboot: Remove code for handling CAN byte Marek Behún
2022-01-26 15:35   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 05/14] tools: kwboot: Do not change received character in kwboot_xm_recv_reply() Marek Behún
2022-01-26 15:38   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 06/14] tools: kwboot: Fix handling of repeated xmodem packets Marek Behún
2022-01-26 15:39   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 07/14] tools: kwboot: Show 'E' in progress output when error occurs Marek Behún
2022-01-26 15:39   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 08/14] tools: kwboot: Allow to use option -b without image path Marek Behún
2022-01-26 15:39   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 09/14] tools: kwboot: Force BootROM to flush input queue after boot pattern Marek Behún
2022-01-26 15:40   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 10/14] tools: kwboot: Remove 2s delay before sending first xmodem packet Marek Behún
2022-01-26 15:41   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 11/14] tools: kwboot: Handle EINTR in kwboot_write() Marek Behún
2022-01-26 15:41   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 12/14] tools: kwboot: Handle EINTR in kwboot_tty_recv() Marek Behún
2022-01-26 15:41   ` Stefan Roese [this message]
2022-01-25 17:13 ` [PATCH u-boot-marvell 13/14] tools: kwboot: Fix usage of -D without -t Marek Behún
2022-01-26 15:42   ` Stefan Roese
2022-01-25 17:13 ` [PATCH u-boot-marvell 14/14] tools: kwboot: Set debug flag to 1 Marek Behún
2022-01-26 15:42   ` Stefan Roese
2022-01-31 11:33 ` [PATCH u-boot-marvell 00/14] Another set of kwboot improvements Stefan Roese

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=7d737949-811a-7018-2c9c-a81e588a9c64@denx.de \
    --to=sr@denx.de \
    --cc=kabel@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.